ro_jero
ro_jero

Reputation: 115

htaccess 301 redirect from third level domain

I have a website, www.example.com And I have a third level domain, start.example.com, which redirects to

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

But somehow Google included pages of the main domain to the third level domain in search, for example

start.example.com/news/ 

So I'd like to redirect 301 all such links to the main domain

start.example.com/news/  =>  www.example.com/news/ 

but keep the first redirect working properly.

How can I do it, help, please?

P.S. First redirect is used for statistics only, with urls like

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

Upvotes: 1

Views: 1538

Answers (1)

anubhava
anubhava

Reputation: 785286

You can try these 2 rules:

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]

Upvotes: 1

Related Questions