David Hinojosa David Hinojosa - 2 months ago 8
PHP Question

Why can't I access new folders on my site? .htaccess issue

when I try to create a new folder on my site, I can not access it. This is a htaccess issue because when I delete the following code, access to the folder is available.

RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)\/$ /game.php?id=$1&title=$2 [L]
RewriteRule ^([^/]*)\/$ /index.php?page=$1 [L]
RewriteRule ^([^/]*)/([^/]*)/([^/]*)\/$ /category.php?cid=$1&page=$2&title=$3 [L]
RewriteRule ^sitemap.xml$ sitemap.php [L]


How can I access my new folder without messing with the functionality of the above code?

Answer

You need to tell it to ignore real files or folders.

RewriteEngine On

#if it's a real file or dir don't rewrite
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

RewriteRule ^([^/]*)/([^/]*)\/$ /game.php?id=$1&title=$2 [L]
RewriteRule ^([^/]*)\/$ /index.php?page=$1 [L]
RewriteRule ^([^/]*)/([^/]*)/([^/]*)\/$ /category.php?cid=$1&page=$2&title=$3 [L]
RewriteRule ^sitemap.xml$ sitemap.php [L]