如何将 index/ 放入 DirectoryIndex? .htaccess.


How to put index/ in DirectoryIndex? .htaccess

如何将index/放在directoryIndex中?

当我访问此 URL 时,本地主机/我的网站/我的网站排列不正确但是当我放置本地主机/我的网站/索引/时,它工作正常。

这是我的htaccess文件

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

提前致谢:)

本地主机/我的网站/索引/= 本地主机/我的网站/索引.php我只是将网页的文件扩展名隐藏为/(斜杠)。

给出 DirectoryIndex 没有任何意义,这是在直接访问一个目录(另一个目录)时提供的文件列表。您可能只想将所有内容重写到该目录。

假设您的 htaccess 文件位于 /mywebsite/ 目录中,然后将其添加到顶部:

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/mywebsite/index
RewriteRule ^$ /mywebsite/index/ [L]

使其看起来像:

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