Welcome to WebmasterWorld Guest from 52.91.39.106

Forum Moderators: Ocean10000 & phranque

Message Too Old, No Replies

301 Redirect Subdomain but not folders and files

Looking to redirect main subdomain index but not the rest

     
2:29 pm on Mar 17, 2014 (gmt 0)

Full Member

10+ Year Member

joined:July 6, 2005
posts:316
votes: 19


Hi,

I had section on the site sub.domain.com. For years had run tens of thousands of news articles in it. However, we stopped publishing that topic a while ago. We recently moved the site and deleted most of the articles in it as rights ran out. Still a few our staff did, but not many. But a lot of search traffic and links to it and its articles.

I was looking to redirect the old sub.domain.com to domain.com but leave the likes of sub.domain.com/folder/ and sub.domain.com/folder/folder/article.html etc alone.

Is that possible? I thought it would be really spammy to redirect all the sub folders (which all have high rank and inbound) as they are specific things we don't cover anymore.

Thing is I was to delete the whole subdomain it would lead to people ending up on another site as name based. Is it a bad idea to redirect the subdomain at all? Its a big site and the subdomain has a lot of page rank and inbound links from newspapers, bbc etc. Its news.domain so figured OK to redirect that to our main page now.

I tried to do it with

RewriteEngine On

RedirectMatch %{HTTP_HOST} news\.sitename\.com$ [NC]
RewriteRule ^ http://www.sitename.com%{REQUEST_URI} [R=301,L,NE]


but that did not work.

Many thanks
James
3:07 pm on Mar 17, 2014 (gmt 0)

Senior Member

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:July 3, 2002
posts:18903
votes: 0


The Regex pattern in the Rule can only match the path part of the request.

As this is localised on a per-folder basis the pattern you require here is
^$


RewriteRule ^$ http://www.example.com/ [R=301,L]
3:47 pm on Mar 17, 2014 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:Apr 9, 2011
posts:15636
votes: 795


RewriteRule ^$ etcetera

Or, if you want to be really thorough,
RewriteRule ^(index\.html)?$


Is it a bad idea to redirect the subdomain at all?

Why don't you serve a 410 with a nice customized 410 page?

RewriteCond %{HTTP_HOST} news\.example\.com$ [NC]
RewriteCond %{REQUEST_URI} !short-list-of-exceptions-here
RewriteRule .? - [G]

The [NE] flag will do no harm, but it isn't needed since nothing in the redirect is escapable anyway. I assume
RedirectMatch

was a typo for
RewriteCond

since it would make no sense (and would probably explode the server) otherwise.
11:53 am on Mar 19, 2014 (gmt 0)

Full Member

10+ Year Member

joined:July 6, 2005
posts:316
votes: 19


Thanks very much folks. I've redirect the main and I will 410 the directory index pages. While leaving the articles not deleted in place. So ideal I think.
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members