Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My wordpress website has seo friendly urls like . I installed wordpress in my /var/www directory.

However, on my server, I also have a directory called /var/www/mywebpage because that directory holds files like /var/www/mywebpage/product1.jpg, /var/www/mywebpage/product2.jpg etc...

Now everytime I go to, the browser gives me a 403 Forbidden error because if a directory with the same name as a wordpress page exists, then the directory takes precedence. I have a few more web directories that suffer from this problem.

How do i edit my .htaccess file such that a wordpress page takes precedence over the following three directories: /var/www/mywebpage, /var/www/myproductpage and /var/www/mygraphics.

However, if someone goes to, i want them to be able to see the physical image file.

Here's my current .htaccess from Wordpress.

#uploaded files
RewriteRule ^(.*/)?files/$ index.php [L]
RewriteCond %{REQUEST_URI} !.*wp-content/plugins.*
RewriteRule ^(.*/)?files/(.*) wp-content/blogs.php?file=$2 [L]

# add a trailing slash to /wp-admin
RewriteCond %{REQUEST_URI} ^.*/wp-admin$
RewriteRule ^(.+)$ $1/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule . - [L]
RewriteRule  ^([_0-9a-zA-Z-]+/)?(wp-.*) $2 [L]
RewriteRule  ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]

RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]

<IfModule mod_security.c>
<Files async-upload.php>
SecFilterEngine Off
SecFilterScanPOST Off
share|improve this question

The simplest answer (and more maintainable in the long run, without getting into more mod_rewrite or mod_alias black magic) is really to not name the directories the same as your seo-friendly-links. Use something like mywebpage_images, myproductpage_images, etc. for these directories.

share|improve this answer
I agree, putting them into an images directory is probably your best bet. – Kyle Buser Oct 5 '10 at 17:58
yes, i agree, but this is part of a legacy issue and I have to preserve these directories and the web page – John Oct 5 '10 at 18:01

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.