This forum has been moved here:
Helicon Tech Community Forum

Helicon Ape (Forum Locked Forum Locked)
 Helicon Tech : Helicon Ape
Subject Topic: Redirecting ALL Files/Folders @ New Site
Author
Message |
taborro
Newbie


Joined: 16 August 2010
Location: United States
Posts: 6
Posted: 13 January 2011 at 11:53am

Hi, couldn't live without your product.  However, I'm a RegEx n00b.  Please have mercy on me ...

I'm trying to 301 an entire website to a single page on a new website.  So, if someone goes to any of these:

http://www.old.com/default.htm
http://www.old.com/something/whatever.htm
http://www.old.com/something/whatever.aspx

It will simple go here:

http://www.new.com/default.aspx

I got the very first scenario to work using this ...

RewriteEngine on
RewriteBase /
RewriteRule default\.htm default.aspx [NC,L]
RewriteRule (.+) http://www.new.com/$1 [R=301]

However, I can't figure out the RegEx for the other cases ... can you please help.  It would be greatly appreciated!
Thank you,
Bob
Back to Top Visit taborro's Homepage
 
Vyacheslav
Admin Group


Joined: 02 July 2008
Location: Ukraine
Posts: 1542
Posted: 13 January 2011 at 12:19pm

Hello.
First of all the rules should be running on www.old.com. Then you might do like this:

Code:
RewriteEngine on
RewriteBase /
RewriteCond $1 /default.htm [NC,OR]
RewriteCond $1 /something/whatever.htm [NC,OR]
RewriteCond $1 /something/whatever.aspx [NC]
RewriteRule (.*) http://www.new.com/$1 [R=301,L]


For more information see mod_rewrite’s documentation

__________________
Slavik Shynkarenko,
Helicon Tech.
Back to Top Visit Vyacheslav's Homepage
 
taborro
Newbie


Joined: 16 August 2010
Location: United States
Posts: 6
Posted: 13 January 2011 at 12:27pm

Thank you for the reply ... please allow me to clarify that I was simply using those URLs as examples ... what I need is ALL folder and files REGARDLESS of where they are in the file system.  There may be dozens of files and folders with files and folders, etc.

So, I'm looking for everything on the old server -- regardless of the number of files and folders -- to be 301'd to the homepage of the new server.  Is there even a way to do that?

Thank you!
Bob


Back to Top Visit taborro's Homepage
 
taborro
Newbie


Joined: 16 August 2010
Location: United States
Posts: 6
Posted: 13 January 2011 at 1:06pm

I figured it out ... I'm a dork ... here's the correct code:

RewriteEngine on
RewriteRule (.*) http://www.learnvisualstudio.net/ [R=301]


Once I omitted the $1 at the end of the URL (which I found on one of your examples) it worked.  Having the first capture group in there didn't work, which caused me to look into the RewriteCond for help.  I apologize for wasting your time.


Edited by taborro - 13 January 2011 at 1:07pm
Back to Top Visit taborro's Homepage
 
Vyacheslav
Admin Group


Joined: 02 July 2008
Location: Ukraine
Posts: 1542
Posted: 13 January 2011 at 1:45pm

But your initial rule already did that. You only should make sure the rules are applied to the website www.old.com.

__________________
Slavik Shynkarenko,
Helicon Tech.
Back to Top Visit Vyacheslav's Homepage
 

Sorry, you can NOT post a reply.
This forum has been locked by a forum administrator.

Printable version Printable version