Reputation: 417
My htaccess
is this :
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^([0-9a-zA-Z-]+)?$ show.php?id=$1 [L]
</IfModule>
So whenever browser get 'any thing' after root folder
then it will go show.php and parameter will be 'any thing' .
Note: it will not effect if it have extension or a folder.
But there is index file in my root folder. So browser should take index file first. So that, i added this in .htaccess
file :
DirectoryIndex index.php
But not working. So is there anything to do, to show at least index file whenever root folder visited ?
Upvotes: 1
Views: 304
Reputation: 785286
You can have your .htaccess like this:
DirectoryIndex index.php
RewriteEngine On
# request is not for a file
RewriteCond %{REQUEST_FILENAME} !-f
# request is not for a directory
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([0-9a-zA-Z-]+)/?$ /show.php?id=$1 [L,QSA]
Upvotes: 1