VideoHive

HTACCESS interfering with real directories! Help?

195 posts
  • Bought between 1 and 9 items
  • Exclusive Author
  • Has been a member for 3-4 years
  • Referred between 1 and 9 users
  • United Kingdom
LionArt says

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 :P

2333 posts
  • Grew a moustache for the Envato Movember competition
  • Community Moderator
  • Elite Author
  • Contributed a Blog Post
  • Won a Competition
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Has been a member for 4-5 years
+8 more
dtbaker moderator says

best to post your existing htaccess

959 posts
  • Sold between 100 and 1 000 dollars
  • Has been a member for 3-4 years
  • Bought between 10 and 49 items
  • Exclusive Author
  • Microlancer Beta Tester
  • United States
fillerspace says

Maybe add a -d -f to your rewrite. This tells Apache to avoid real directories and files.

195 posts
  • Bought between 1 and 9 items
  • Exclusive Author
  • Has been a member for 3-4 years
  • Referred between 1 and 9 users
  • United Kingdom
LionArt says
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]
195 posts
  • Bought between 1 and 9 items
  • Exclusive Author
  • Has been a member for 3-4 years
  • Referred between 1 and 9 users
  • United Kingdom
LionArt says

Anyone have a simpler way of doing this? or one that will recognize real directories?

92 posts
  • Bought between 50 and 99 items
  • Exclusive Author
  • Has been a member for 3-4 years
  • Referred between 1 and 9 users
  • Sold between 10 000 and 50 000 dollars
  • United States
CodeFusion says
2333 posts
  • Grew a moustache for the Envato Movember competition
  • Community Moderator
  • Elite Author
  • Contributed a Blog Post
  • Won a Competition
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Has been a member for 4-5 years
+8 more
dtbaker moderator says

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)
195 posts
  • Bought between 1 and 9 items
  • Exclusive Author
  • Has been a member for 3-4 years
  • Referred between 1 and 9 users
  • United Kingdom
LionArt says

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

This give me the same issue as before. :(

Try seeing for yourself… http://www.hostpyro.com

Try clicking on “blog” or “forum”.

195 posts
  • Bought between 1 and 9 items
  • Exclusive Author
  • Has been a member for 3-4 years
  • Referred between 1 and 9 users
  • United Kingdom
LionArt says
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.

by
by
by
by
by