Forum Topic: Redirect URL with Question Mark in URI

Forum: .htaccess Forum : Redirecting • Posted by John Arstingstall • Updated:

I’m trying to redirect:


I’ve tried quite a few different solutions and nothing has worked. If any one can guide me in the right direction I would really appreciate it.


4 Replies to “Redirect URL with Question Mark in URI”

Posted by Jeff Starr

Hi John,

That looks like this should work:

RewriteCond %{QUERY_STRING} view [NC]
RewriteRule .* [R=301,L]

The first line matches any query string that includes the term “view”, and then the second line redirects the request to the homepage. The question mark at the end strips the query string from the URL.

Posted by John Arstingstall •

Thanks Jeff,

It works!

Posted by Mohammed •


I have a question covering redirection too:

We have a Portfolio page and our issus is that the links are dynamic to filter the projects in the same page. So the links are like that:

We would need this kind of link through htaccess:

We did use some JS to load a pseudo rewriting of the URL. So at the moment the page is called once then we add through JS the “good” URL.

Hope I’m clear otherwise I will send you a private link to the website.

Any help is sincerly welcome.

Best regards,


Posted by Jeff Starr

It’s straightforward to redirect based on query string, but the trick is knowing the new URL for each of the redirects (e.g., the “neuilly-sur-seine” in your example). If you have that information available to .htaccess, then do query-string redirects like so:

RewriteCond %{QUERY_STRING} pid=319 [NC]
RewriteRule .* [R=301,L]

I hope that is useful. Also, for future reference, please open a new thread for each issue, thanks.