| Welcome to WebmasterWorld Guest from 220.127.116.11 |
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
|Subscribe to WebmasterWorld|
|Chaging Folder Names|
best redirect or rewrite method?
| 11:01 am on Aug 15, 2011 (gmt 0)|
I will be changing the names of 20 directories on a site, but changing no file names.
After reading about a dozen archived threads on 'redirect' and 'rewrite', I got a bit .. er, seriously confused.
I think what I am after is an "External URL" redirect, i.e., the pages are indexed in SE's and I want the visitor clicking the links to see the pages under the new directory structure.
Looks like one way is to do 20 entries in my .htaccess file like:
RewriteRule ^/old-name/$1 http://www.example.com/new-name/$1 [R=301,L]
Is this anywhere close to being right?
Is there an easier way?
| 11:13 am on Aug 15, 2011 (gmt 0)|
[edited by: g1smd at 11:16 am (utc) on Aug 15, 2011]
| 11:16 am on Aug 15, 2011 (gmt 0)|
Are you changing the names of the physical folders on the hard drive and want new URLs for those folders?
Are you changing the names of the physical folders on the hard drive and want to keep the same old URLs for those folders?
Do you simply want to assign new folder names within the URLs while leaving the physical folder names on the hard drive untouched?
Do you want to assign new folder names within the URLs and new folder names on the physical hard drive?
All four things are possible. URLs are a reference system used on the web, and physical folders exist on your server hard drive. The two are not at all the same thing.
They are related merely by the action of the server "mapping" URL requests to the physical hard drive locations. You can alter that mapping using rewrites.
If a resource has a new URL, then you use a redirect to inform the browser that asks for the old URL that it needs to now go look some place else.
The redirect code you supplied was almost right:
RewriteRule ^old-name/(.*) http://www.example.com/new-name/$1 [R=301,L]
| 7:18 am on Aug 16, 2011 (gmt 0)|
I want to change the names of the physical folders on the hard drive -- but need incoming links from other sites and SE's to find the newly named (directories) pages -- and not produce 404's.
Thanks for correcting that code for me! :)
At one time a couple of years ago, someone pointed me to a self-help page, sort of a 'cook book' for .htacess on Apache. I thought it was in the 'library', but a search didn't find it.
All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
© Webmaster World 1996-2013 all rights reserved