【发布时间】:2017-03-24 10:21:13
【问题描述】:
我启用了 mod_rewrite 并使用phpinfo() 进行了检查。
我放置了一个 .htaccess 文件
RewriteEngine on
RewriteRule ^(.*)$ index.php?/$1 [L]
和 apache 根目录 (/var/www/html/) 中的 index.php 文件。
工作网址:
http://192.168.56.101/index.php
http://192.168.56.101/index.php/edrgderg
失败的 (404) 网址:
http://192.168.56.101/sgghsshgfhfgj
Mod_rewrite 应该将其形成为 http://192.168.56.101/index.php/sgghsshgfhfgj,但事实并非如此。
我想将每个请求重定向到index.php。
解决方案:
我不得不编辑我的 apache 配置:
sudo nano /etc/apache2/sites-enabled/000-default.conf
我补充说:
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
【问题讨论】:
-
你想达到什么目的?看起来您想将每个请求重定向到
index.php -
没错,我的实际重写更具体一些,但这是(不工作,)棘手的部分。
标签: php apache .htaccess mod-rewrite url-rewriting