首页 > 解决方案 > 为什么我网站的所有子路径都找不到 404?

问题描述

最近我配置了我的服务器(LAMP)并上传了我的网站。主页运行良好,但所有其余页面都返回404 not found。我猜这个问题与.htaccess文件有关。这是.htaccess根目录中存在的文件:

RewriteEngine on

Options -Indexes

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# this doesn't work on some version of xampp
# RewriteRule ^(.*)$ index.php?rt=$1 [L,QSA]

RewriteRule ^([\s\S]*)$ index.php?rt=$1 [L,B,QSA]

ErrorDocument 404 /error404.html


Options -Indexes

<Files *.php>
    Order Deny,Allow
    Deny from all
    Allow from ::1
</Files>

<Files index.php>
    Order Allow,Deny
    Allow from all
</Files>

注意服务器操作系统是ubuntu 16.04。知道如何解决这个问题吗?

标签: phpapache.htaccessubuntu-16.04

解决方案


<Files *.php>
    Order Deny,Allow
    Deny from all
    Allow from ::1
</Files>

阻止除 index.php (这是您的主页)之外的所有 .php 文件。


推荐阅读