Reputation: 2395
I'm trying to change the $_GET['p'] variable in my url to it's own, but without the ?=.
Example:
www.example.com/?p=about to www.example.com/about
The problem is that my bit of htaccess code also reacts to subfolders aswell.
If I want to access my images folder as an example, I get:
www.example.com/images/?p=images
How do I make sure my .htaccess ignores any subfolder?
This is the .htaccess I'm currently using
RewriteEngine on
RewriteBase /
# Rewrite page include
#RewriteRule ^(\w+)$ index.php?p=$1
Sorry for my bad explaination.
-Banana
Upvotes: 0
Views: 129
Reputation: 7866
RewriteEngine on
# ignore existing files (only apply to non-file)
RewriteCond %{REQUEST_FILENAME} !-f
#ignore folders (only apply to non-folder)
RewriteCond %{REQUEST_FILENAME} !-d
# here you might also want to exclude some specific locations...
RewriteCond %{REQUEST_URI} !^(images|css|js)/
# finally, apply the rule...
RewriteRule ^(\w+)$ index.php?p=$1 [L]
All the RewriteCond
conditions are chained (only if all of them pass, then the rule is applied).
Upvotes: 1