我正在尝试使用以下方式创建友好的网址:
Options +Indexes
Options +FollowSymLinks
Options -MultiViews
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/?$ /index.php?lang=$1&page=$2&subpage=$3 [L,QSA]
</IfModule>
我尝试时一切正常:
www.mydomain.com/en/my-page /
OR
www.mydomain.com/en/my-page/my-subpage /
但是,当我尝试此操作时出现404错误:
www.mydomain.com/en/
我一直在努力理解这个问题。 提前谢谢。
Options +Indexes
Options +FollowSymLinks
Options -MultiViews
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} ^/([^/]+)/?([^/]*)?/?([^/]*)?/?([^/]*)?/? [NC]
RewriteRule .* index.php?lang=%1&page=%2&subpage=%3&anotherkey=%4 [L]
</IfModule>
答案 0 :(得分:0)
有这样的话:
Options +Indexes
Options +FollowSymLinks
Options -MultiViews
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ /index.php?lang=$1&page=$2&subpage=$3 [L,QSA]
RewriteRule ^([^/]+)/([^/]+)/?$ /index.php?lang=$1&page=$2 [L,QSA]
RewriteRule ^([^/]+)/?$ /index.php?lang=$1 [L,QSA]
</IfModule>