Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex htaccess 301从三级域重定向_Regex_Apache_.htaccess_Mod Rewrite_Redirect - Fatal编程技术网

Regex htaccess 301从三级域重定向

Regex htaccess 301从三级域重定向,regex,apache,.htaccess,mod-rewrite,redirect,Regex,Apache,.htaccess,Mod Rewrite,Redirect,我有一个网站,www.example.com 我有一个三级域名start.example.com,它重定向到 RewriteCond %{HTTP_HOST} ^start.example\.com$ [NC] RewriteRule ^(.*)$ index.php?start=1&$1 但不知怎的,谷歌在搜索中把主域名的页面添加到了第三级域名, 比如说 start.example.com/news/ 所以我想将所有这些链接重定向到主域 start.example.com/new

我有一个网站,www.example.com 我有一个三级域名start.example.com,它重定向到

RewriteCond %{HTTP_HOST} ^start.example\.com$ [NC]
RewriteRule ^(.*)$ index.php?start=1&$1
但不知怎的,谷歌在搜索中把主域名的页面添加到了第三级域名, 比如说

start.example.com/news/ 
所以我想将所有这些链接重定向到主域

start.example.com/news/  =>  www.example.com/news/ 
但是要保持第一个重定向正常工作

我怎么做,请帮忙

注意:第一个重定向仅用于统计,URL如下

start.example.com/?utm_source=whatever&utm_medium=start 

您可以尝试以下两条规则:

RewriteCond %{HTTP_HOST} ^start\.example\.com$ [NC]
RewriteRule ^([^/.]*)$ index.php?start=1&$1 [L,QSA]

RewriteCond %{HTTP_HOST} ^start\.example\.com$ [NC]
RewriteRule !^index\.php$ http://www.example.com%{REQUEST_URI} [L,R=301]

您可以尝试以下两条规则:

RewriteCond %{HTTP_HOST} ^start\.example\.com$ [NC]
RewriteRule ^([^/.]*)$ index.php?start=1&$1 [L,QSA]

RewriteCond %{HTTP_HOST} ^start\.example\.com$ [NC]
RewriteRule !^index\.php$ http://www.example.com%{REQUEST_URI} [L,R=301]