开发者

How use htaccess for seo friendly url with subdomains?

This is my htacess file:

RewriteEngine on    
RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTP_HOST} ^(.*)\.mydomain\.com(.*)
RewriteRule .* inside.php?tx=%1&filter=%2 

This url: hello.mydomain.com goes to www.mydomain.com/inside.php?tx=hello Thats correct.

Now 开发者_如何学Ci need this url hello.mydomain.com/bye/ goes to www.mydomain.com/inside.php?tx=hello&filter=bye, but don't work. Only goes to www.mydomain.com/inside.php?tx=hello

This htaccess is ignoring the second variable (bye). Help please.


%{HTTP_HOST} only contains the host name (hello.mydomain.com), so your second backreference doesn't have anything in it. Changing your RewriteRule to the following should give the behaviour you're expecting:

RewriteRule ^([^/]*) inside.php?tx=%1&filter=$1 

Edit: To correct the situation described in your comment, the entire ruleset should be as follows:

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTP_HOST} ^(.*)\.mydomain\.com(.*)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]*) inside.php?tx=%1&filter=$1
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜