Can anyone help me with adding the redirect rules to my .htaccess? I want to redirect websites visitors based on the URL they enter. For example:
- If a visitor enters URL without www to be redirected to my root (index.php)
- If a visitor enters URL, but with the WWW to be redirected to http://domain.com/home/index.html
Edit: From your description above and your comment below, it sounds like you want requests to be redirected like this:
www.domain.com -> domain.com/home/index.html www.domain.com/about.php -> domain.com/home/index.html domain.com -> domain.com/index.php domain.com/home/index.html -> domain.com/index.php domain.com/news.php?id=5 -> domain.com/index.php
If not, please replace this edit with some corrected examples.
Best Answer
Try these rules:
But note that if you’re redirecting to the same host (like the first rule probably does), you will get an infinite recursion. So you might want to delimit the first rule by excluding
/home/index.html
: