Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

.htaccess rewrite to subdomain and redirect

Status
Not open for further replies.

vexxy

Technical User
Aug 23, 2012
2
RO
Hey guys,

I'm in a bit of a situation. I want to change my rewrite rules for a folder to a subdomain and then redirect old rules to new ones (for SEO).

So basically I have this:

Code:
RewriteEngine On
RewriteBase /
RewriteRule ^news/index([0-9-]+)\.html$ index.php?page=pressrelease_homepage&pn=$1
RewriteRule ^news/$ index.php?page=pressrelease_homepage
RewriteRule ^press/([a-zA-Z0-9-]+)-([0-9-]+)\.html$ index.php?page=pressrelease_page&id=$2

I want to rewrite everything to press.site.com and everything /press/ to press.site.com. After I do this, I want to redirect all old links to the new subdomain links. I tried several methods but I wasn't very successful.

Any help will be greatful!
 
For folder to subdomain mod_alias rule is the way to go.

Code:
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/news/(.*)$ [OR]
RewriteCond %{REQUEST_URI} ^/press/(.*)$
RewriteRule .* [URL unfurl="true"]http://press.domain.tld/%1[/URL] [R]

vexxy said:
After I do this, I want to redirect all old links to the new subdomain links. I tried several methods but I wasn't very successful.

Example needed of the request URIs and the URI they are to go to

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top