Apache, Rewrite Rule and Directories
- by milo5b
my sites-available/ file looks something like the following:
<VirtualHost *:80>
ServerAdmin webmaster@mysite
ServerName mysite.co.uk
ServerAlias www.mysite.co.uk
DocumentRoot /home/mysite.co.uk/htdocs/
<Directory /home/mysite.co.uk/htdocs/>
Options -Indexes FollowSymlinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/mysite.co.uk/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/mysite.co.uk/access.log combined
</VirtualHost>
In .htaccess (in the htdocs/), I have (amongst others) the following rewrite rule:
RewriteRule ^enquiries$ /enquiries.php
Somehow I have also a directory named "enquiries" (/home/mysite.co.uk/htdocs/enquiries/), and when I hit the url "www.mysite.co.uk/enquiries" I get:
HTTP/1.1 301 Moved Permanently
Date: Mon, 10 Dec 2012 18:53:37 GMT
Server: Apache/2.2.16 (Debian)
Location: http://www.mysite.co.uk/enquiries/
Vary: Accept-Encoding
Content-Type: text/html; charset=iso-8859-1
And a Browser would display the directory's content. Now, I could easily rename the folder and get it sorted, but I would like to understand what's going on here.
What would be the correct way to configure Apache in a way that it wont behave this way, and instead would listen to the Rewrite Rule?
If I did not explain myself clearly, please feel free to ask more questions, I'd be happy to answer them. Thanks!