I’m doing some work for a friend on their website, and while we are working on the new site I would like to set up their .htaccess file to redirect users with the following rules:
- Redirect any requests to / or /index.html to a subdirectory (e.g. both
http://example.com/andhttp://example.com/index.htmlshould redirect tohttp://example.com/legacy/index.html) - Allow direct requests to index.php to pass through without redirect (e.g.
http://example.com/index.php) - If possible, requests to a second subdirectory get redirected to index.php (e.g.
http://example.com/beta/redirects tohttp://example.com/index.php)
This is probably a simple request, but I have no experience with the rules language that .htaccess uses.
Thanks in advance!!
Redirect any requests to
/or/index.htmlto a subdirectory (e.g. bothhttp://example.com/andhttp://example.com/index.htmlshould redirect tohttp://example.com/legacy/index.html)Allow direct requests to index.php to pass through without redirect (e.g.
http://example.com/index.php)If possible, requests to a second subdirectory get redirected to index.php (e.g. http://example.com/beta/ redirects to
http://example.com/index.php)These would all go in the htaccess file in your document root. If you actually wanted to redirect the browser so that the URL in the address bar changes, include a
R=301in the square brackets:[L,R=301]. If when you say “requests to a second subdirectory get redirected to index.php” meaning “any subdirectory”, then the rule needs to be changed to: