mod_rewrite 不工作
我是服务器管理新手,但我能够在我的新 VPS 上运行 LAMP 设置。我上传了一些在我的其他服务器上工作的网络文件,但它们似乎在我的 /var/log/apache2/error.log 文件中给了我错误:“文件不存在”。通过我的脚本,主页可以正常加载,但其他页面则不能。
.htaccess 文件代码
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?r=$1 [L,QSA]
我已在服务器上启用了 mod_rewrite,并且可以看到它在我创建的 phpinfo() 页面下运行。根本不知道为什么会出现这个问题。如果我需要发布其他内容,请告诉我:)
I'm new to server administration but I was able to get a LAMP setup running on my new VPS. I uploaded a few web files that work on my other server, but they seem to give me the error: "File does not exist" in my /var/log/apache2/error.log file. The homepage loads just fine through my scripting, but other pages don't.
.htaccess file code
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?r=$1 [L,QSA]
I have enabled mod_rewrite on the server and can see it running under my phpinfo() page I have created. Simply don't know why this issue is happening. If I need to post anything else, please let me know :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您的网站或虚拟主机似乎尚未被授予处理
.htaccess
文件的适当权限。您可以通过故意犯一个语法错误来轻松测试它:如果您的网站没有崩溃,则该文件将被忽略。在您的主
httpd.conf
文件中尝试类似的操作:... 或这样(根据您的喜好):
It looks like your site or virtual host has not been granted the appropriate permissions to process
.htaccess
files. You can test it easily by making a syntax error on purpose: if your site does not crash, the file is being ignored.Try something like this in your main
httpd.conf
file:... or this (to your liking):
当我遇到这个问题时,发现
/etc/apache2/sites-enabled/000-default
具有AllowOverride All
,但是/etc/apache2 /apache2.conf
也为我们的 WebDirectory
提供了相同的条目,其中包含AllowOverwrite None
。所以一定要检查这两个地方!When I had this problem it turned out that the
/etc/apache2/sites-enabled/000-default
had theAllowOverride All
, but the/etc/apache2/apache2.conf
also had the same entry for our webDirectory
withAllowOverwrite None
. So be sure to check both places!错误:模块重写不存在
二月 21, 2014 作者 Sharad Chhetri 发表评论
在 Ubuntu 中处理 Apache 模块时,我发现 Apache Web Server 中存在重写问题。我尝试启用重写模块,但收到此错误错误:模块重写不存在!。故障排除后,我发现问题出在 mod_rewrite 模块上。
经过一些更多的故障排除后,发现 /etc/apache2/mods-available/ 中缺少 rewrite.load 文件。
现在,我检查了 mod_rewrite.so 实际模块文件,哇,它就在那里。
下面给出的是我运行的逐步命令,以解决此问题。这是我的系统
root@tuxworld 的参考:~# a2enmod rewrite
错误:模块重写不存在!
root@tuxworld:~# ls -l /usr/lib/apache2/modules/mod_rewrite.so
-rw-r--r-- 1 root root 58728 2020 年 5 月 28 日 /usr/lib/apache2/modules/mod_rewrite.so
root @tuxworld:~#
root@tuxworld:~# echo "LoadModule rewrite_module
/usr/lib/apache2/modules/mod_rewrite.so" > /etc/apache2/mods-available/rewrite.load
root@tuxworld:~#
root@tuxworld:~# a2enmod rewrite启用模块重写。
要激活新配置,您需要运行:
service apache2 restart
root@tuxworld:~#
之后我重新启动了 apache2 服务
sudo service apache2 restart
ERROR: Module rewrite does not exist
February 21, 2014 by Sharad Chhetri Leave a Comment
While working on Apache Module in Ubuntu,I found rewrite problem in Apache Web Server.I tried to enable the rewrite module but got this error ERROR: Module rewrite does not exist!.After troubleshooting,I found the problem was with mod_rewrite module.
After doing some more troubleshooting,it is found that the rewrite.load file was missing in /etc/apache2/mods-available/ .
Now,I checked the mod_rewrite.so actual module file and Wow it was there.
Below given is step by step command which I ran,to solve this issue.Here is the reference from my system
root@tuxworld:~# a2enmod rewrite
ERROR: Module rewrite does not exist!
root@tuxworld:~# ls -l /usr/lib/apache2/modules/mod_rewrite.so
-rw-r--r-- 1 root root 58728 May 28 2020 /usr/lib/apache2/modules/mod_rewrite.so
root@tuxworld:~#
root@tuxworld:~# echo "LoadModule rewrite_module
/usr/lib/apache2/modules/mod_rewrite.so" > /etc/apache2/mods-available/rewrite.load
root@tuxworld:~#
root@tuxworld:~# a2enmod rewriteEnabling module rewrite.
To activate the new configuration, you need to run:
service apache2 restart
root@tuxworld:~#
After this I restarted the apache2 service
sudo service apache2 restart