Reputation: 493
how can i put index/ in directoryIndex?
when i access this url localhost/mywebsite/ my website is not properly arrange but when i put localhost/mywebsite/index/ it works fine.
here is my htaccess file
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/$ $1.php
RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]
DirectoryIndex index.php index.php3 index.html index.htm index/ <-- i add this
thanks in advance :)
PS. localhost/mywebsite/index/ = localhost/mywebsite/index.php i just hide the file extension of my webpages to /(slash).
Upvotes: 1
Views: 1290
Reputation: 143966
It doesn't make any sense to give DirectoryIndex
, which is a list of files that gets served in the event a directory is directly accessed, another directory. You probably want to just rewrite everything to that directory.
Assuming that your htaccess file is in the /mywebsite/
directory, then add this to the top:
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/mywebsite/index
RewriteRule ^$ /mywebsite/index/ [L]
so that it looks like:
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/mywebsite/index
RewriteRule ^$ /mywebsite/index/ [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/$ $1.php
RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]
DirectoryIndex index.php index.php3 index.html index.htm
Upvotes: 1