Reputation: 16598
I want to convert an entity query like 'http://www.mysite.com/users' to 'http://www.mysite.com/entities.php?entityName=users'.
How to make such a rewrite rule? Or what should I put into my .htaccess?
Would be great to preserve original url variables, like convert 'http://www.mysite.com/users?fields=ID,UUID' to 'http://www.mysite.com/entities.php?entityName=users&fields=ID,UUID'.
Upvotes: 1
Views: 576
Reputation: 4469
If you want to rewrite (and not to redirect) /$users to /entities.php?entityName=$users while preserving the original query string, like rewrite /$users?fields=ID,UUID to /entities.php?entityName=$users&fields=ID,UUID then you could try this:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9_-]+)/?$ /entities.php?entityName=$1 [QSA]
Upvotes: 2