目前我对漂亮的网址有一条重写规则,工作正常。我尝试在一秒钟内添加,它给了我一些问题:
# redirect /?p=xyz to /xyz
RewriteCond %{QUERY_STRING} ^p=(.*)$
RewriteRule ^(.*)$ /index.php/%1 [L]
# Removes index.php from ExpressionEngine URLs
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
第二个工作正常,但第一个是给我内部服务器错误。基本上我想要任何东西?p = *去/index.php / *
[编辑]只是为了澄清,我需要http://domain.com/?p=test等同于http://domain.com/test/
答案 0 :(得分:2)
domain.com/test
至domain.com/?p=test
请改为尝试:
Options +FollowSymlinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} !p= [NC]
RewriteRule ^([^/]+)/? /?p=$1 [L,NC]
如果是相反的话:
domain.com/?p=test
至domain.com/test/index.php
试试这个:
Options +FollowSymlinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} p=([^/]+) [NC]
RewriteRule .* /%1/index.php? [L,NC]
如果不需要,请删除index.php
,如下所示:
RewriteRule .* /%1/? [L,NC]