开发者

Always WWW modrewrite php

开发者 https://www.devze.com 2023-03-17 01:10 出处:网络
I want to force www in my urls. I\'m having problems with writing. I know that this code will do the trick.

I want to force www in my urls. I'm having problems with writing. I know that this code will do the trick.

RewriteCond %{HTTP_HOST} ^example.com 
RewriteRule ^(.*)$ http://www.example.com/$1
开发者_运维技巧

But I want to put all in $_GET['page']

RewriteRule ^(.*)$ /index.php?page=$1 [L]

How should I put this together?


You need to add [QSA], which allows you to modify the query string of the URL:

RewriteRule ^(.*)$ /index.php?page=$1 [QSA,L]


this should do the job

RewriteCond %{HTTP_HOST} ^example.com 
RewriteRule ^(.*)$ http://www.example.com/$1
RewriteCond %{REQUEST_URI} !^/index.php
RewriteRule .* index.php?page=$0 [L]
0

精彩评论

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

关注公众号