当其他函数正常工作时,apache重写规则被忽略(Apache rewrite rule is getting ignored while other functions are working pr

编程入门 行业动态 更新时间:2024-10-25 10:22:14
当其他函数正常工作时,apache重写规则被忽略(Apache rewrite rule is getting ignored while other functions are working properly)

我在Ubuntu 14.04上运行LAMP服务器,一切似乎都配置正常。 唯一的问题是,重写规则以某种方式被忽略而不发出任何错误。 修改.htaccess文件后,页面会像往常一样重新加载。 我想要做的是使用以下代码将所有流量路由到index.php:

RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteRule . index.php [L]

其他规则运作正常,例如。 如果我deny from all添加deny from all并重新加载页面,我立即得到错误。 所有文件和文件夹都位于/ var / www / root目录中。 我不知道这里缺少什么,我花了几个小时调试这个问题没有解决方案:(。

谢谢

I have LAMP server running on Ubuntu 14.04, and everything seems to be configured fine. The Only problem that am having is that, the rewrite rule is somehow getting ignored without issuing any error. The page reloads again as usual after modifying the .htaccess file. What I am trying to do, is to route all traffic to index.php using the following code:

RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteRule . index.php [L]

Other rules are functioning properly, eg. if I add deny from all and reload the page,I immediately get en error. All files and folders are located in the /var/www/ root directory. I don't know what am missing here, I spent hours debugging this issue without a solution :(.

最满意答案

这个. 只会匹配一个字符。 尝试使用.*来匹配任何东西。

RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteRule .* index.php [L]

I found a solution to redirect all traffic to index.php by pointing the document root to index.php:

<VirtualHost *:80> ServerAdmin admin@example.com ServerName example.com ServerAlias www.example.com DocumentRoot /var/www/example.com/index.php </VirtualHost>

thanks @Chris for the help.

更多推荐

index,php,The,问题,电脑培训,计算机培训,IT培训"/> <meta name="description&

本文发布于:2023-07-28 18:42:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1307979.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重写   函数   规则   工作   apache

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!