htaccess - Rewrite PHP $_GET only in root

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

Answers


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).


Need Your Help

Connect to local MySQL database in JBoss EWS 2.0

mysql jboss openshift

I created an OpenShift application (Tomcat 7 (JBoss EWS 2.0)) and with the help of developercorey I was able to deploy my application to OpenShift and connect to the the local MySQL database in

How to draw circle on multiple canvas html5?

javascript html css canvas

I want to draw circle on responsive canvas using javascript. I am getting width and height of canvas, but because of div tag width and height % I am able to draw circle properly. The div tag width ...