Reputation: 621
This could be probably duplicate due to unable to find that original even after checked the similar questions list of stackoverflow. Actually if user type myipaddress/gt then it should redirect to myipaddress/gt/gt.htm I tried various mod_rewrites but still gets the 'gt' folder contents listed in browser. I gave the last try with below mod_rewrite.
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteRule ^gt$ gt/gt.htm [NC,L]
But still the browser shows the contents of the 'gt' folder. What am I doing wrong?
Upvotes: 1
Views: 76
Reputation: 9007
Due to the fact that Apache sees gt
as a directory, it treats it as such. However, that doesn't stop all rewriting for that particular path.
This is the basic process:
/gt
./gt/
.This is why you still see the directory listing.
As such, you should change your rule to this:
RewriteRule ^gt/$ gt/gt.php [NC,L]
Alternatively, you can make use of DirectorySlash off
and make the trailing slash optional, like so:
Options +FollowSymlinks
DirectorySlash off
RewriteEngine On
RewriteBase /
RewriteRule ^gt/?$ gt/gt.php [NC,L]
Doing either of the above allows you to have multiple rules of a similar nature in a single .htaccess
file.
Upvotes: 0
Reputation: 785128
You can use this rule in /gt/.htaccess
:
Options +FollowSymlinks
RewriteEngine On
RewriteBase /gt/
RewriteRule ^/?$ gt.php [L]
Upvotes: 1