Forum Moderators: phranque
So lets say user hits [localhost...] he will be shown the index page but if he types [localhost...] he should not be taken to this directory/location and instead redirected to [localhost...] loading the index page.
Environment is as follows:
OS: Linux
Server: Apache
Backend is developed in PHP.
To achieve this I am using the .htaccess file with following rules
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} !^localhost/
RewriteRule ^(.*)$ [localhost...] [L,R=301]
Here the redirection happens properly but the rewrite condition (RewriteCond) which is put to avoid looping to [localhost...] doesn’t seem to be working. The browser is throwing error.
I want to avoid doing this using httpd.conf file of Apache as the application will be distributed and making changes to httpd.conf will not the advisable/feasible.
Any help in this context or suggestions for alternatives will be highly appreciated.
Thanks in advance.
RewriteRule / http://%{HTTP_HOST}/ [R=301,L]
RewriteRule / - [F]
^/[^/]*(/[^/]*)+$ will be required. Jim