Jump to content

rewrite and redirecting to subdomain


vexx

Recommended Posts

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:

 

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 www.site.com/news 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!

Link to comment
Share on other sites

in the code I posted I didn't try..it's just the original code...I did have some attempts based on some suggestions I had but with no success. It's worth mentioning that I'm in my learning stage now and I would definitely love some help in this particular case :)

 

tnx!

Link to comment
Share on other sites

If you can give couple of examples of redirect you want to do - it would be better. Both /press and /news to press.site.com is kind of confusing.

 

A simple rewrite for example.com/press/something to press.example.com/something would be like the one below

 

 

RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule ^press/(.*)$ http://sub.example.com/$1 [R=301,L]

 

Believe you are expecting something different mentioning about old urls and new urls for SEO. Examples would illustrate better.

 

Link to comment
Share on other sites

yep, I appoligize:

 

the homepage, so to speak, is www.site.com/news/  ... i want this press.site.com

All the links from the "news" section are www.site.com/press/press-name.html ...i want this press.site.com/press-name.html

 

Tnx alot!

Link to comment
Share on other sites

that will work for redirecting the old urls to the new ones, but I kinda need the rewrite rule for the subdomain

 

Now I have this:

 

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

 

and I need to rewrite the subdomain like this

 

RewriteRule ^press.site.com/index([0-9-]+)\.html$ index.php?page=pressrelease_homepage&pn=$1

RewriteRule ^press.site.com/$ index.php?page=pressrelease_homepage

RewriteRule ^press.site.com/([a-zA-Z0-9-]+)-([0-9-]+)\.html$ index.php?page=pressrelease_page&id=$2

 

Evidently, those rewrite rules don't work..so that's why I need some help

 

Thanks again!

Link to comment
Share on other sites

Unless I am misunderstanding what you are expecting, you can target your sub domain like this correct?

 

 

RewriteEngine On
RewriteCond %{HTTP_HOST} ^sub\.example\.com$ [NC]
RewriteRule ^(/)?$ index.php?page=pressrelease_homepage [L]
RewriteRule ^index([0-9-]+)\.html$ index.php?page=pressrelease_homepage&pn=$1 [L]
RewriteRule ^([a-zA-Z0-9-]+)-([0-9-]+)\.html$ index.php?page=pressrelease_page&id=$2 [L]

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.