2013-02-14 70 views
0

所以我使用Kohana这是有用的,如果你知道它,但不需要帮助我。Mod_Rewrite重写目录我不希望它

我有以下mod_rewrite的规则:

# Allow any files or directories that exist to be displayed directly 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_URI} !^/store/.*$ 

# Rewrite all other URLs to index.php/URL 
RewriteRule .* index.php [L] 

所以我试图改写为不存在index.php文件和目录的所有请求。

但是,我希望发送到mydomain.com/store/*的任何请求都通过,因为在store目录中有另一个htaccess文件可以在那里工作。目前看来这似乎不奏效。有任何想法吗?

完整的htaccess:

# Turn on URL rewriting 
RewriteEngine On 

# Installation directory 
RewriteBase/

#ErrorDocument 404 http://www.mydomain.com/404Page.html 
#Options +FollowSymlinks 

# Protect hidden files from being viewed 
<Files .*> 
    Order Deny,Allow 
    Deny From All 
</Files> 


RewriteCond %{REMOTE_ADDR} !^myip 
RewriteCond %{REQUEST_URI} !^/maintenance\.html$ 
RewriteRule ^(.*)$ http://www.mydomain.com/maintenance.html [R=307,L] 

##301 Redirect Rules## 
#some 301 redirects i did not include here 

##Kohana Redirect Rules## 

# Protect application and system files from being viewed 
RewriteRule ^(?:application|modules|system|kohana|vendors)\b.* http://www.mydomain.com/ [L] 

# Allow any files or directories that exist to be displayed directly 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_URI} !^/?store/ 

# Rewrite all other URLs to index.php/URL 
RewriteRule .* index.php [L] 
+0

注意我还尝试了以下规则:'RewriteRule^store - [L,NC]' – thatidiotguy 2013-02-14 18:37:19

+0

如果'/ store'是一个物理目录,'!-d'检查就足够了,'/ store'条件不会是必要的。别的地方有点不对劲。 – 2013-02-14 19:05:41

+0

@SalmanA你是完全正确的。我是白痴,并没有在实际商店direkry – thatidiotguy 2013-02-14 19:40:56

回答

0

问题原来是在store目录中的.htaccess文件中,而不是webroot中的.htaccess文件中。谢谢大家,并为我的愚蠢感到抱歉。如果有人想留下关于如何为未来用户调试这种性质的东西的评论,那将是非常棒的。

1

试试这个条件:

RewriteCond %{REQUEST_URI} !^/?store/ 

没有必要的目录后检查字符。如果我正确记住是第一个斜杠,并且只有在服务器配置不包含尾部斜线时才显示,那么我将第一个斜杠设置为可选。

+0

没有看到htaccess文件,它仍然在做。即时通讯将发布完整的文件,也许有什么我在这里失踪 – thatidiotguy 2013-02-14 18:34:32