Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mod_rewrite not working

Tags:

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 :)

like image 216
RhapX Avatar asked Sep 19 '10 18:09

RhapX


People also ask

What is mod_rewrite module?

The mod_rewrite module is a rule-based Apache engine for rewriting URLs. The rules allow writing various queries to change URLs into the desired format. Some applications include page redirecting or proxy fetching. This article shows how to set up, configure, and rewrite URLs using mod_rewrite.

How do I know if .htaccess is working?

Save the file and type the URL yoursite.com/foobar/ . If the reditect works and the URL gets redireted to the homepage of example.com then it's clear that your htaccess is working and being read by your Apache server. If it still doesn't work then the problem might be that your hosting provider has not enabled it.


1 Answers

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> 
like image 107
Álvaro González Avatar answered Oct 10 '22 23:10

Álvaro González