.htaccess在此服务器上找不到请求的url / public / index

时间:2015-11-09 23:57:13

标签: apache .htaccess mod-rewrite digital-ocean

您好我刚刚完成设置我的服务器和我的所有代码文件但我遇到了问题。每当我转到https://www.frindse.com/index时,它都会给我一个错误,指出找不到/ public / index文件。

我的网站设置方式是所有请求都转到公共文件夹,该文件夹包含我的index.php文件,该文件路由我的所有页面。不是在我的本地服务器上一切都完美无缺,但在我的digitalocean服务器上,每当我进入索引页面它都无法正常工作。但是,如果我去https://www.frindse.com/login页面加载完美。这就是我的.htaccess文件在我的公共文件夹中查找的方式,该文件夹路由我的所有页面和请求:

<IfModule mod_rewrite.c>
RewriteEngine On

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

RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]

</IfModule>

此处还有我网站根目录中的.htaccess文件。它将所有调用路由到公用文件夹:

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule    ^$    public/    [L]
    RewriteRule    (.*) public/$1    [L]
 </IfModule>

还要记住,我的服务器上已经激活了mod_rewrite,并且我已经在我的数字中心中将AllowOverride设置为All。

1 个答案:

答案 0 :(得分:0)

尝试将重写库添加到公用文件夹中的.htaccess。并关闭多视图以获得良好的衡量标准。

Options -MultiViews
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /public/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l

RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]

</IfModule>

实际上,为什么你甚至需要公共文件夹中的.htaccess文件?只需将请求直接路由到索引文件,如根中的 .htaccess文件,然后删除公用文件夹中的文件。

    Options -MultiViews
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d [OR]
    RewriteCond %{REQUEST_FILENAME} -l
    RewriteRule ^ - [L]

    RewriteRule ^$ public/ [L]
    RewriteRule ^(.*)$ /public/index.php?url=$1 [QSA,L]

    </IfModule>