Jump to content
rjn

.htaccess Rewrite

Recommended Posts

I currently have the foolowing to redirect from the old domain name to the new domain name:

RewriteEngine on

RewriteCond %{HTTP_HOST} ^\.oldsite\.biz\.*$ [NC]

RewriteCond %{HTTP_HOST} ^\.oldsite\.$ [NC]

RewriteRule ^(.*)$ http://www.newsite.com/$1 [R=301,L]

 

The above does redirect a visitor accessing the homepage, but does not work if accessing through other pages / extensions (e.g., www.oldsite.biz/xyz.php). I searched online and found nothing that worked.

 

It seems as if the solution should be simple - any recommendations?

Share this post


Link to post
Share on other sites

I've used something like this before for redirecting to a subfolder. I changed the code a little. See if this works.

>RewriteEngine On
Options +FollowSymlinks
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.oldsite.*
RewriteRule ^(.*)$ http://www.newsite.com/$1
RewriteCond %{HTTP_HOST} ^oldsite.*
RewriteRule ^(.*)$ http://www.newsite.com/$1

Share this post


Link to post
Share on other sites

Thumper, thanks for the suggestion, but it didn't work. I get an Internal Server error warning.

 

I've used something like this before for redirecting to a subfolder.  I changed the code a little.  See if this works.

>RewriteEngine On
Options +FollowSymlinks
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.oldsite.*
RewriteRule ^(.*)$ http://www.newsite.com/$1
RewriteCond %{HTTP_HOST} ^oldsite.*
RewriteRule ^(.*)$ http://www.newsite.com/$1

Share this post


Link to post
Share on other sites

I test it a little, and got this much. Maybe it can help you some. It works, but it changes the domain name. Maybe this can get someone else on the right track.

>RewriteEngine On
Options +FollowSymlinks
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.oldsite.*
RewriteRule  ^(.*)$ http://www.newsite.com/$1
RewriteCond %{HTTP_HOST} ^oldsite.*
RewriteRule  ^(.*)$ http://www.newsite.com/$1

Share this post


Link to post
Share on other sites

Anyone esle out there want to offer some help in coding this .htaccess file or recommend another option?

 

I test it a little, and got this much. Maybe it can help you some. It works, but it changes the domain name.  Maybe this can get someone else on the right track.

>RewriteEngine On
Options +FollowSymlinks
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.oldsite.*
RewriteRule  ^(.*)$ http://www.newsite.com/$1
RewriteCond %{HTTP_HOST} ^oldsite.*
RewriteRule  ^(.*)$ http://www.newsite.com/$1

Share this post


Link to post
Share on other sites

You said you received a 500 Internal Server Error using that code in your .htaccess file. I'd suggest looking at the Error Log in your CPanel and see what the error message is - it should indicate what is wrong with the .htaccess file.

Share this post


Link to post
Share on other sites

I'm a little uncertain what you're trying to achieve. Do you want all the other pages/extensions to keep their old address but show the pages from the new site? Then why not just park those domains over the new one? That seems the simplist way.

 

But if you want everything to show the address of the new site, so that www.oldsite.com/xyz.html will show www.newsite.com/xyz.html in the status bar, try this:

 

>RewriteCond %{HTTP_HOST} ^www\.oldsite\.com$ [NC]
RewriteCond %{HTTP_HOST} ^oldsite\.com$ [NC]
RewriteRule ^(.*)$ http://www.newsite.com/$1 [R=301,L]

 

This won't mask the new URL--people will see they've been directed to it. But it should let someone who is trying to access a specific page on the old address find it on the new site.

 

If you want the old URL to stay in the status bar, parking the domain seems like the easiest and least complicated solution.

Share this post


Link to post
Share on other sites

Or if you really are just shunting traffic from one site to the next:

 

>RewriteRule /.* http://mynewdomain.com/ [R=301,L]

Share this post


Link to post
Share on other sites

Thanks for the suggestions, but nothing is working.

 

Or if you really are just shunting traffic from one site to the next:

 

>RewriteRule /.* http://mynewdomain.com/ [R=301,L]

Share this post


Link to post
Share on other sites

The Original .htaccess we set up for you was

>RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.oldiste\.biz$ [NC]
RewriteRule ^(.*)$ [url=http://newsite.com/$1]http://newsite.com/$1[/url] [R=301,L]

 

Per our conversations :)

Share this post


Link to post
Share on other sites

Here's my shot at it:

>RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.oldsite\.biz$ [NC,OR]
RewriteCond %{HTTP_HOST} ^oldsite\.biz$ [NC]
RewriteRule ^(.*)$ http://www.newsite.com/$1 [R=301,L]

Share this post


Link to post
Share on other sites

You are the winner :)

 

;)

 

Here's my shot at it:

>RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.oldsite\.biz$ [NC,OR]
RewriteCond %{HTTP_HOST} ^oldsite\.biz$ [NC]
RewriteRule ^(.*)$ http://www.newsite.com/$1 [R=301,L]

Share this post


Link to post
Share on other sites

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.   Paste as plain text instead

  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...