homepage Welcome to WebmasterWorld Guest from 54.237.213.31
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Chaging Folder Names
best redirect or rewrite method?
old_expat

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 4351553 posted 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?

 

g1smd

WebmasterWorld Senior Member g1smd us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4351553 posted 11:13 am on Aug 15, 2011 (gmt 0)

nnijoh

[edited by: g1smd at 11:16 am (utc) on Aug 15, 2011]

g1smd

WebmasterWorld Senior Member g1smd us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4351553 posted 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]
old_expat

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 4351553 posted 7:18 am on Aug 16, 2011 (gmt 0)

Hi g1smd,

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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved