Forum Moderators: phranque

Message Too Old, No Replies

How to redirect www.example.com/stuff to www.example.com

         

Perfection

2:02 pm on Sep 29, 2007 (gmt 0)

10+ Year Member



I'm currently redirecting non-www to www, and index.html to http://www.example.com.

Now I'm looking to redirect both http://www.example.com/stuff and http://www.example.com/things to http://www.example.com

But of course, I'm having some trouble figuring out how to do this. Any help would be greatly appreciated.

[edited by: jdMorgan at 2:25 pm (utc) on Sep. 29, 2007]
[edit reason] example.com [/edit]

g1smd

9:52 pm on Sep 29, 2007 (gmt 0)

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



What have you tried so far?

You are going
from ^whatever(/.*) to http://www.example.com$1 or
from ^whatever/(.*) to http://www.example.com/$1 each time.

Perfection

10:47 pm on Sep 29, 2007 (gmt 0)

10+ Year Member



I haven't really tried anything, as I am fairly clueless about where to start. The current redirects I have going are only working properly because I either copied them line for line out of a tutorial years ago, or I asked here and one of you fine people helped me. =)

I'm just trying to get requests for www.example.com/things and www.example.com/stuff to redirect to www.example.com

However, I do NOT want www.example.com/stuff/more-stuff.html or www.example.com/things/more-things.html to redirect.

g1smd

10:57 pm on Sep 29, 2007 (gmt 0)

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



>> www.example.com/things <<

Do you want both non-www and www to redirect, 'cus if you do you need that in this same rule to prevent a redirection chain?

Do you want only /things to redirect, or do you also want /things/ with a trailing "/" to also redirect?

For the first, it sounds like you'll need ^whatever$ to redirect to http://www.example.com/.

If you need the version with trailing / to redirect, then you don't need a separate rule, you can add a question mark to make the final character optional: ^whatever/?$ where the $ sign end-anchors the pattern.

[edited by: g1smd at 11:05 pm (utc) on Sep. 29, 2007]

Perfection

11:01 pm on Sep 29, 2007 (gmt 0)

10+ Year Member



"Do you want both non-www and www to redirect, 'cus if you do you need that in this same rule to prevent a redirection chain?"

Yes, I'd want both non-www and www to redirect.

"Do you want only /things to redirect, or do you also want /things/ with a trailing "/" to also redirect?"

Both with and without the trailing slash.