.htaccess 如何将htaccess用于搜索引擎优化友好的子域url?

.htaccess 如何将htaccess用于搜索引擎优化友好的子域url?,.htaccess,.htaccess,这是我的htacess文件: RewriteEngine on RewriteCond %{HTTP_HOST} !^www\. RewriteCond %{HTTP_HOST} ^(.*)\.mydomain\.com(.*) RewriteRule .* inside.php?tx=%1&filter=%2 此url:hello.mydomain.com转到www.mydomain.com/inside.php?tx=hello 没错 现在我需要这个url hello.m

这是我的htacess文件:

RewriteEngine on    
RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTP_HOST} ^(.*)\.mydomain\.com(.*)
RewriteRule .* inside.php?tx=%1&filter=%2 
此url:hello.mydomain.com转到www.mydomain.com/inside.php?tx=hello 没错

现在我需要这个url hello.mydomain.com/bye/进入www.mydomain.com/inside.php?tx=hello&filter=bye,但不起作用。只能访问www.mydomain.com/inside.php?tx=hello


此htaccess正在忽略第二个变量(bye)。请提供帮助。

%{HTTP\u HOST}
仅包含主机名(
hello.mydomain.com
),因此您的第二个反向引用中没有任何内容。将您的
重写规则
更改为以下内容应该会给出您期望的行为:

RewriteRule ^([^/]*) inside.php?tx=%1&filter=$1 
编辑:要纠正评论中描述的情况,整个规则集应如下所示:

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

感谢您的回答,我将rewriterule更改为:rewriterule^([^/]*)inside.php?tx=%1&filter=$1,但现在这个url:hello.mydomain.com/bye/转到:www.mydomain.com/inside.php?tx=hello&filter=inside.php