I would like to ignore all query-strings in my redirect. How would I achieve this?
Basically, /project/(.*)
should always redirect to /?tag=project&id=$1
/project/100?shareid=fromsomeemailprovider
should end et the ? and only redirect to Id 100.
Thank You!
I tried the following:
^/project/([^/]*)[/]?(.*)$
/?tag=project&id=$1&$2
to put the query-string behind another &, but this only works if the first URL hast a /
at the end of it, which it often hasn't and the RewriteRule can't detect the ?
sadly.
CodePudding user response:
With your shown samples, please try following htaccess rules file.
RewriteEngine ON
RewriteRule ^(project)/(.*)/?$ index.php?tag=$1&id=$2 [QSA,NC,L]
Please make sure:
- You clear your browser cache before testing your URLs.
- You make sure to keep your
index.php
file along with your htaccess rules file. Also add/
in case both of these files are in root location in your system.