开发者

mod_rewrite not working

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_FIL开发者_StackOverflow社区ENAME} !-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 :)


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:

<Directory "/path/to/your/site">
    AllowOverride All
</Directory>

... or this (to your liking):

<VirtualHost *:80>
    AllowOverride All
</VirtualHost>


When I had this problem it turned out that the /etc/apache2/sites-enabled/000-default had the AllowOverride All, but the /etc/apache2/apache2.conf also had the same entry for our web Directory with AllowOverwrite None. So be sure to check both places!


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜