开发者

Simple htaccess mod rewrite with possible query string

开发者 https://www.devze.com 2023-02-14 05:07 出处:网络
I\'ve tried and tried and tried by my htaccess knowledge isn\'t great, and I cannot find anything to suit my needs (but then I\'m not sure what i\'m searching for).

I've tried and tried and tried by my htaccess knowledge isn't great, and I cannot find anything to suit my needs (but then I'm not sure what i'm searching for).

Effectively my question is twofold:

I want to convert: http://subdomain.domain.com/hello

To: http://subdomain.domain.com/index.php?string=hello

But occasionally there could be a querystring as well so...

From: http://subdomain.domain.com/hello?query=true

To: http://subdomain.domain.com/index.php?string=hello&query=true

So far I've managed the first:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -f [NC,OR]
RewriteCond %{REQUEST_FILENAME} -d [NC]
RewriteRule .* - [L]
RewriteRule ^([^/\.]+)/?$ client开发者_高级运维.php?user=$1&$2 [L]

Remember, the second is a potential :) Thanks!


You just need to set the QSA flag for the last rule:

RewriteRule ^([^/\.]+)/?$ client.php?user=$1 [L,QSA]

Then the original requested query will automatically appended to the new one.

0

精彩评论

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