我有以下.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 :(得分:0)
您是否已将RewriteBase相应更改为子目录?