2012-01-09 67 views
-2

我有以下.htaccess文件。为什么.htaccess在子目录中不起作用?

问题是,它在根目录中正常工作,但在子目录中没有问题。 任何人都可以帮我解决这个问题吗?

Options +FollowSymLinks -Indexes 
RewriteEngine on 

RewriteBase/

#non-www to www 
RewriteCond %{HTTP_HOST} ^example.com [NC] 
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L] 

# index.php to/
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.php\ HTTP/ 
RewriteRule ^(([^/]+/)*[^.]+)index\.php$ /$1 [R=301,L] 

#index/123/ to index.php?menu=123 
RewriteRule ^index2/([^/]+)/?$ /index2.php?menu=$1 [L] 

#index.php?menu=123 to index/123/ 
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index2\.php\?menu=([^&]+)\ HTTP/ 
RewriteRule ^index2\.php$ http://example.com/index2/%1/? [R=301,L] 

# Unless directory, remove trailing slash 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^([^/]+)/$ http://example.com/$1 [R=301,L] 

# Redirect external .php requests to extensionless url 
RewriteCond %{THE_REQUEST} ^(.*)\.php([#?][^\ ]*)?\ HTTP/ 
RewriteRule ^(.+)\.php$ http://example.com/$1 [R=301,L] 

# Resolve .php file for extensionless php urls 
RewriteRule ^([^/.]+)$ $1.php [L] 

ErrorDocument 404 /404.php 
ErrorDocument 403 /403.php 
+0

它不适用于某些子目录或所有子目录吗?你能否提供一些不起作用的示例URL和你期望发生的事情 – 2012-01-09 17:26:51

+0

它不适用于所有子目录。 – Nevca 2012-01-09 17:28:30

+0

事实上,删除“index.php”的规则适用于所有子目录,但其他规则不适用。一个人认为问题出在变数上,但我自己不足以修改它们。 – Nevca 2012-01-09 17:30:04

回答

0

您是否已将RewriteBase相应地更改为子目录?

+0

是的,我尝试过,但我有同样的问题。 – Nevca 2012-01-09 17:21:51

相关问题