重写查询登录网址

时间:2014-11-18 05:35:25

标签: regex .htaccess mod-rewrite url-rewriting

我在请求uri ex:

的midle中有查询的url
http://domain.com/index.php?/recipe_category/recipe/

我也试图删除index.php,但它会留下查询符号(?),以便网址变为

http://domain.com/?/recipe_category/recipe/

如何删除所有[index.php?]?为了您的信息,我的htaccess写如下:

RewriteEngine On

RewriteCond %{SERVER_NAME} !^www.domain.com$
RewriteRule .* http://www.domain.com%{REQUEST_URI} [R=301,L]
RewriteRule ^index.php/(.*)$ http://www.domain.com/$1 [R=302,L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php
RewriteRule ^index\.php$ / [L,R=301]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|robots\.txt|sitemap\.xml)
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]

1 个答案:

答案 0 :(得分:0)

您可以使用以下行删除" index.php?"

RewriteEngine On

RewriteRule ^ index.php \?(。*)$ http://www.domain.com/ $ 1 [R = 302,L]