这是我的htacess文件:
This is my htacess file:
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.
RewriteCond %{HTTP_HOST} ^(.*).mydomain.com(.*)
RewriteRule .* inside.php?tx=%1&filter=%2
此网址:hello.mydomain.com去www.mydomain.com/inside.php?tx=hello~~V 那是正确的。
This url: hello.mydomain.com goes to www.mydomain.com/inside.php?tx=hello Thats correct.
现在我需要这个网址hello.mydomain.com/bye/去www.mydomain.com/inside.php?tx=hello&filter=bye~~V,但不起作用。只到www.mydomain.com/inside.php?tx=hello~~V
Now i 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
这htaccess的是忽略了第二个变量(再见)。请帮助。
This htaccess is ignoring the second variable (bye). Help please.
%{HTTP_HOST}
仅包含主机名( hello.mydomain。 COM
),那么你的第二个反向引用不具有任何东西。改变你的重写规则
以下是应该给你期望的行为:
%{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
编辑:要更正您的评论描述的情况,整个规则集应该如下:
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