Forum Moderators: phranque

Message Too Old, No Replies

Redirecting

         

oktar

6:04 pm on Aug 3, 2006 (gmt 0)

10+ Year Member



How to redirect all pages under the domain without typing Redirect 302 url_of_the_page destination_url for every page that the site has?

jdMorgan

6:28 pm on Aug 3, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The Apache mod_alias Redirect directive [httpd.apache.org] uses prefix-matching; Any URL that starts with the specified local URL-path will be redirected to the new URL, with the unmatched remainder of the requested URL appended to that new URL.

Example:


Redirect 301 /directoryA/ http://www.example.com/directoryB/

This will redirect *all* 'files' requested from /directoryA/ to the same-named files in /directoryB/

such as: http://example.com/directoryA/salem.html --301--> http://www.example.com/directoryB/salem.html

Jim

oktar

6:49 pm on Aug 3, 2006 (gmt 0)

10+ Year Member



Thanks but it doesn't work for me. I want to redirect all pages from selected directories from site A to the _main page_ of site B.

With Redirect 301 /dir/ [siteb.com...] it tries to redirect to [siteb.com...] and not to the main page.

jdMorgan

7:50 pm on Aug 3, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> all pages from selected directories from site A to the _main page_ of site B.

Well, you should have said so. I was quite specific about the Redirect above...

You'll need RedirectMatch [httpd.apache.org] instead then - You might want to read all of the mod_alias document; I've linked you to it twice now. :)


RedirectMatch 301 ^/dir/(.*)$ http://siteb.com/

Jim

oktar

8:01 pm on Aug 3, 2006 (gmt 0)

10+ Year Member



Thanks a lot!