Reputation: 79
I have a question about how to rewrite an url properly.
I want to rewrite each url to index.php?p=thatpage, for example
Param1 does not have the name param1 and it should be possible to add more parameters. At this moment I have:
RewriteRule ^([a-z]+)*$ ./index.php?p=$1
Which works fine for the first two, but doesn't for the last.
Optional it would be nice to don't rewrite an URL if it starts with 'img' or 'layout'.
Thanks in advance!
Upvotes: 0
Views: 54
Reputation: 68790
You can use the [QSA]
tag to append the query string to your redirection :
RewriteRule ^(.+?)/?$ ./index.php?p=$1 [QSA]
(I changed [a-z]+
into .+
to get it working with slashes)
For your additionnal request, here's how to disable url rewriting for a specific folder:
RewriteEngine On
RewriteRule ^img/ - [L]
RewriteRule ^layout/ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+?)/?$ index.php?p=$1 [QSA,L]
Upvotes: 2