Php 如何访问子目录:

Php 如何访问子目录:,php,html,.htaccess,subdirectory,Php,Html,.htaccess,Subdirectory,出于某些原因,在我的网站上,我只能访问根文件夹中的网站,如下所示: http://domain-name.com/[file] 但我无法访问子目录。例如,以下操作不起作用: http://domain-name.com/[folder1]/[file] 我使用Hostinger作为我的网络主机。我感觉我的.htaccess配置不正确。以下是当前的.htaccess: RewriteEngine On # Unless directory, remove trailing slash Rew

出于某些原因,在我的网站上,我只能访问根文件夹中的网站,如下所示:

http://domain-name.com/[file]
但我无法访问子目录。例如,以下操作不起作用:

http://domain-name.com/[folder1]/[file]
我使用Hostinger作为我的网络主机。我感觉我的.htaccess配置不正确。以下是当前的.htaccess:

RewriteEngine On

# Unless directory, remove trailing slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/$ http://domain-name.com/$1 [R=301,L]

# Redirect external .php requests to extensionless url
RewriteCond %{THE_REQUEST} ^(.+)\.php([#?][^\ ]*)?\ HTTP/
RewriteRule ^(.+)\.php$ http://domain-name.com/$1 [R=301,L]

# Resolve .php file for extensionless php urls
RewriteRule ^([^/.]+)$ $1.php [L]

您只需在下面为apache和nginx的示例编写所需文件扩展名的规则:

apache配置 重新启动发动机 重写规则!\。js | gif | jpg | jpeg | png | ico | css | eot | svg | swf | ttf | woff | woff2 | map | pdf | doc docx | rar | zip$index.php nginx配置 地点/{ 重写!\.js | gif | jpg | jpeg | png | ico | css | eot | svg | swf | ttf | woff | woff2 | map | pdf | doc doc docx | rar | zip$/index.php;
}检查一下,看看它是否回答了您的问题:从上一条规则的模式中删除斜杠。