Forum Moderators: phranque

Message Too Old, No Replies

Permanent Redirect of Entire Directory to New URL

using .htaccess

         

riospace

4:07 pm on Apr 8, 2007 (gmt 0)

10+ Year Member



I want to permanently redirect an entire directory on my site to a different URL. Is the following the correct way to achieve this in .htaccess:

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

[edited by: jdMorgan at 4:49 pm (utc) on April 8, 2007]
[edit reason] example.com [/edit]

gabriel01

10:21 pm on Apr 10, 2007 (gmt 0)

10+ Year Member



That looks fine.

gabriel01

10:42 pm on Apr 10, 2007 (gmt 0)

10+ Year Member



Another way to do it is as follows:

Redirect permanent /[i]your-directory[/i] http://www.example.com/

A request to /your-directory/blah.htm would be redirected to http://www.example.com.

Or like this:

Redirect permanent /[i]your-directory[/i][b]/[/b] http://www.example.com/

A request to /your-directory/blah.htm would be redirected to http://www.example.com/blah.htm.

g1smd

12:17 am on Apr 13, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Do you actually want to redirect, where the URL in the browser actually changes and a 301 is issued? or do you want to just internally rewrite the URL so that what the user sees does not actually change?

Your answer to that decides what to do next...

riospace

2:04 pm on May 1, 2007 (gmt 0)

10+ Year Member



I want to redirect, where the URL in the browser actually changes and a 301 is issued.