Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

My wordpress website has seo friendly urls like http://mysite.com/mywebpage . 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 http://mysite.com/mywebpage, 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 http://mysite.com/mywebpage/product1.jpg, i want them to be able to see the physical image file.

Here's my current .htaccess from Wordpress.

# WORDPRESS Rules below, DO NOT EDIT!
#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
</Files>
share|improve this question
add comment

1 Answer 1

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
add comment

Your Answer

 
discard

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.