开发者

Apache RewriteRule - Can't remove "index.php?q="

开发者 https://www.devze.com 2023-03-28 22:24 出处:网络
I\'m testing .htaccess file on the server. The goal is to convert www.mysite.com/index.php?q=help into mysite.com/help

I'm testing .htaccess file on the server. The goal is to convert www.mysite.com/index.php?q=help into mysite.com/help

1)to remove www. 2) to remove index.php?q=

My .htaccess in the root directory contains:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ /index.php?q=$1 [L] 

Nothing happens - index.php?q=help is still there... Does anybody know, why?

Thank you.

Matthew, thanks again. Here is another version, the problem solved for 50%.

RewriteEngine On 
RewriteCond %{HTTP_HOST} ^www.mysite.com$ [NC] 
RewriteRule ^(.*)$ http://mysite.com/$1 [L,R=301] #removes www., works fine 
RewriteRule开发者_C百科 ^index\.php/?$ http://mysite.com/ [NC,R,L] #still doesn't work - it does not remove index.php as needed


The original request will still be there due to RewriteCond %{REQUEST_FILENAME} !-f

0

精彩评论

暂无评论...
验证码 换一张
取 消