Reputation: 15959
# php_value session.cookie_domain .rhr.fm
# Enable Rewrite Engine
RewriteEngine on
#Create friendly URL
RewriteRule ^(data|cache)($|/) - [L]
RewriteRule ^([^/]+) index.php?page=$1 [L]
Hello once again Stackoverflow!
I would like to redirect URLs for SEO on my website, that
www.example.com/about
www.example.com/?page=about
and
www.example.com/about/
www.example.com?page=about
But the dirs data
and cache
get excluded, so that
www.example.com/data/js/page.js
does not redirect to
www.example.com/?page=data/js/page.js
I've tried the code above but that didn't work out - $_GET['page']
allways dumps index.php
.
Could you please help me?
Thanks in advance!
Upvotes: 4
Views: 8942
Reputation: 786091
This should work:
RewriteEngine on
#Create friendly URL
RewriteRule ^(data|cache)($|/) - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ /index.php?page=$1 [L,QSA]
2nd rule will skip all files and directories from rewrite due to 2 RewriteCond
statements.
Upvotes: 3