【问题标题】:htaccess redirect rules don't workhtaccess 重定向规则不起作用
【发布时间】:2018-03-13 10:13:21
【问题描述】:

我是 htaccess 新手,所以请不要评判我 :)。 我有以下问题 - 我正在我的本地服务器/它的 apache2/ 中创建一个网站,并且该项目位于 www/html/subFolder/MVC 中。 在 MVC 文件夹中,我有以下结构

MVC
|-- .htaccess
|-- app
||-- bootstrap.php
||-- .htaccess
||-- config
||-- controllers
||-- helpers
||-- libraries
|||-- controller.php
|||-- core.php
||`-- database.php
||-- models
|`-- views
`-- public
|-- .htaccess
|-- css
|-- img
|-- index.php
`-- js

问题是我尝试为公用文件夹制定重定向规则。例如,当用户尝试打开 MVC/public/test.php /一些不存在的文件/时,它应该将其重定向到 MVC/public/index.php,但我的规则不起作用 这是我在公共文件夹中的 htaccess 文件

<IfModule mod_rewrite.c>
 Options -Multiviews
 RewriteEngine On
 RewriteBase /MVC/public
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
</IfModule>

这是我在根文件夹中的 htaccess

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

【问题讨论】:

    标签: php .htaccess


    【解决方案1】:

    在 apache 的主配置中,我不允许覆盖我的 htaccess 文件。我只是为那个 O 添加一个规则

    Options +SymLinksIfOwnerMatch
    AllowOverride all
    

    现在一切正常

    【讨论】:

      猜你喜欢
      • 2014-07-20
      • 2020-04-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多