2012-01-09 65 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

相關問題