Forum Moderators: phranque

Message Too Old, No Replies

Urgent help on Mod Rewite pls (301)

moving server, changing folder names, retaining filenames

         

JLSeagull

8:47 pm on Jul 6, 2006 (gmt 0)

10+ Year Member



I do hope some good samaritan would take some time out to help me here. Many thanks in advance for thinking of helping me. Here it goes:

I have an urgent directive to shift all content from our present server to our new server. Although all the filenames (dynamic url's) would remain the same, but the folder location is changing (universally) across the board. Here's the scenario:

At present, the url's are like: http://example.com/portal/modules.php?name=01e_page_title

What we need now is:

http://example.com/modules.php?name=01e_page_title

so, each query string that appears as a part of url containing /portal/ after companyname.com would remain the same, except that /portal/ folder would vanish.

Is there some way to write just one universal command to accomplish this using Redirect 301?

With best wishes
JLS

[edited by: jatar_k at 9:01 pm (utc) on July 6, 2006]
[edit reason] examplified [/edit]

jdMorgan

11:28 pm on Jul 6, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If your purpose is simply to 'recover' the old /portal/ style backlinks, then this is a rather simple single-rule solution. All you have to do is use mod_rewrite to redirect ^/portal/(.*)$ to http://example.com/$1

You don't even need to worry about the query string -- mod_rewrite's default handling of query strings is to leave them unchanged and simply pass them through the rewrite operation.

You will have to change all the page-generation code to stop putting /portal/ in the on-page links, since those are the links that people will click on and that robots will "see," but the simple mod_rewrite described above will take care of the pre-existing backlinks.

Jim