Hey guys.
So it seems that my HTACCESS mod_rewrite function that changes (file).php into /(file) is interfering with real directories. My HTACCESS file is trying to find a php file from a directory named “pages” and when trying to access directories like ”/blog” with a wordpress installation on it, it returns an error saying…
“Not Found
The requested URL /pages/blog.php was not found on this server.”
Is there any possible way I could make a rewrite function to avoid particular directories? I really do not want to have to leave my url’s with ”.php” extensions!
Thanks in advance, LionArt.
EDIT : I have put this in all marketplaces because there is either CodeCanyon or ThemeForest that this could go on… I needed both 
- Grew a moustache for the Envato Movember competition
- Community Moderator
- Contributed a Blog Post
- Author was Featured
- Item was Featured
- Won a Competition
- Repeatedly Helped protect Envato Marketplaces against copyright violations
- Has been a member for 4-5 years
best to post your existing htaccess
Maybe add a -d -f to your rewrite. This tells Apache to avoid real directories and files.
RewriteEngine On RewriteRule ^([a-zA-Z0-9_-]+)$ /pages/$1.php RewriteRule ^([a-zA-Z0-9_-]+)/$ /pages/$1.php RewriteRule ^manage/ - [L] RewriteRule ^/forum/ - [L] RewriteRule ^blog/ - [L]
Anyone have a simpler way of doing this? or one that will recognize real directories?
I use this when hiding PHP extension: http://www.spencerdrager.com/2010/02/07/hide-php-extension-in-url-using-htaccess/
- Grew a moustache for the Envato Movember competition
- Community Moderator
- Contributed a Blog Post
- Author was Featured
- Item was Featured
- Won a Competition
- Repeatedly Helped protect Envato Marketplaces against copyright violations
- Has been a member for 4-5 years
you could try:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9_-]+)$ /pages/$1.php
RewriteRule ^([a-zA-Z0-9_-]+)/$ /pages/$1.php
you could also try my favorite:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ rewrite.php [L,QSA]
and inside rewrite.php you do all the calculations as to what file or files you need to include or run (eg: maybe initialize a database script before including /pages/foo.php)dtbaker said
you could try:RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([a-zA-Z0-9_-]+)$ /pages/$1.php RewriteRule ^([a-zA-Z0-9_-]+)/$ /pages/$1.phpThis give me the same issue as before.
Try seeing for yourself… http://www.hostpyro.com
Try clicking on “blog” or “forum”.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?page=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ index.php?page=$1
This is the code I’m using now, it’s still not working. It’s still trying to find real directories as “pages/(pagename).php”.
Can anyone PLEASE help.

