Forum Moderators: phranque

Message Too Old, No Replies

how to redirect plages to main domain

         

kaksiviisi

8:03 pm on Feb 8, 2010 (gmt 0)

10+ Year Member



Good day.

I have been searching around to find a solution for my problem.

I would like to redirect pages like

www.mydomain.com/subsite/funny/year/month/date/
www.mydomain.com/subsite/notice/year/month/date/
www.mydomain.com/subsite/amazing/year/month/date/
.
.
.

to my main domain

www.myadomain.com/

Can anyone kindly please suggest me a solution? Thank you very much for your time and help.

Have a nice day.

jdMorgan

2:09 pm on Feb 9, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



See Apache mod_alias and mod_rewrite documentation at apache.org and examples in our Apache Forum Library.

Either the RedirectMatch directive in mod_alias or the RewriteRule directive in mod_rewrite can easily be used to solve this problem.

Jim

kaksiviisi

3:04 pm on Feb 9, 2010 (gmt 0)

10+ Year Member



Thanks jdMorgan. I managed to get it done.

Sharing the code here

RewriteRule ^subsite\/?(.*)$ "http\:\/\/www\.example\.com\/" [R=301,L]

[edited by: jdMorgan at 3:33 pm (utc) on Feb 9, 2010]
[edit reason] example.com [/edit]

jdMorgan

3:32 pm on Feb 9, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You don't need all that escaping, the back-reference declaration, or the "/?" in the pattern. Add a question mark to the substitution if you wish to clear any/all query strings:

RewriteRule ^subsite http://www.example.com/? [R=301,L]

Jim