-1

I want to redirect this:

http://www.site.com/xyz

To

http://www.site.com/

Basically i want to redirect to the root domain if a user types anything else after the first slash of my domain name like /xyz or anything else should be redirected or rewritten as the root URL in the browser. Can anybody help? Thanks for your help!

(*** This should be only for the first time like when a new user comes to visit my page, because once the page loads for the first time i do not want any re directions as i have different directories, and related webpages. Otherwise my visitor will only see landing page. )

1 Answer 1

2

Do you want the rewrite to happen even if site.com/xyz is a valid URL?

In that case I think you should redirect with your PHP/whatever you're running based on a cookie instead of redirecting everything. (Since I don't think it's possible to redirect/not redirect based on previous visits with only mod_rewrite)

If you only want to redirect invalid URLs you can use the ErrorDocument-directive, or mod_rewrite with the -f flag to RewriteRule.

Not the answer you're looking for? Browse other questions tagged .