Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

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
    ErrorLog ${APACHE_LOG_DIR}/mysite.co.uk/error.log
    LogLevel warn
    CustomLog ${APACHE_LOG_DIR}/mysite.co.uk/access.log combined

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!

share|improve this question
Are you saying that you cannot view the folders contents because the rewrite is catching the word enquiries and creating an endless loop? –  Anagio Dec 10 '12 at 22:57
No, I am saying I cannot redirect from a path that has the same name of a directory. No loops happens, I just see the content of the directory instead of seeing the correct file that apache should redirect to –  milo5b Dec 11 '12 at 15:46
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.