如何设置med .htaccess文件,以便将www.mydomain.com/index.php?page=home重写为www.mydomain.com/home?
我尝试过这段代码,但它并不像我想要的那样。
RewriteEngine On RewriteBase /
# Removes index.php from ExpressionEngine URLs
RewriteCond %{THE_REQUEST} ^GET.*index\.php?page= [NC]
RewriteCond %{REQUEST_URI} !/system/.* [NC]
RewriteRule ^([^/]+)/? index.php [L,QSA]
# Directs all EE web requests through the site index file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?page=$1 [L]
答案 0 :(得分:0)
您的第一个重定向规则不正确。您可以使用:
RewriteEngine On
RewriteBase /
# Removes index.php from ExpressionEngine URLs
RewriteCond %{THE_REQUEST} /index\.php\?page=([^\s&]+) [NC]
RewriteCond %{REQUEST_URI} !/system/.* [NC]
RewriteRule ^ /%1? [R=302,L,NE]
# Directs all EE web requests through the site index file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ /index.php?page=$1 [L,QSA]