I have this:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ $1.php [QSA]
To remove ".php" extensions, and it works great. I have been playing around with adding another rules, however it gets ignored. I need a second rule to say:
example.php/"variable" then sub it with example.php?page=variable
URL the user sees:
example.com/folder/example/variable
Actual page is example.com/folder/example?page=variable
I have a basic understanding of the rewrite engine, but I'm no expert. Thanks!
You need to add another condition to your php rule, one that checks if the rewrite destination actually exists. Afte rthat, you want pretty much the same thing but you check for the path info:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI}.php -f
RewriteRule ^(.*)$ $1.php [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/(.*)/([^/]+)$
RewriteCond %{DOCUMENT_ROOT}/%1.php -f
RewriteRule ^(.*)/([^/]+)$ /$1.php?page=$2 [L,QSA]