We have just moved to a new website and discovered that our 301 redirects do not work. The URLs from the old website contain question marks which I can now see cause issues with redirects.

To complicate this further, I cannot access the .htaccess file as we are using a hosted website service (Odoo).

An example URL from our old website was "/shopping.asp?intDepartmentId=2"

I have tried adding a / or \ before the ?, but to no avail.

Any suggestions?

  • You should add you redirects to your question
    – John Conde
    Jun 16, 2023 at 22:04
  • 1
    The "question marks" are called a "query string".
    – Steve
    Jun 16, 2023 at 22:30
  • 1
    What would need to be done in the .htaccess (or server configuration) is answered on StackOverflow: How to redirect URLs based on query string?. I have no idea what your options are with Odoo. If you can't access files via FTP or a file manager, you should probably contact Odoo with your delimma. I just went to my cPanel for a shared hosting account and created a redirect containing a query string to see how it would be handled. The resulting redirect in the .htaccess did not include the query string.
    – Tim R
    Jun 17, 2023 at 0:22
  • How did you set up the 301 redirects?
    – davidgo
    Jun 17, 2023 at 5:53

1 Answer 1


The RewriteCond is different for the case of using a query string. A second RewriteCond is used for the string thus two RewriteCond

# Redirect Query String
<IfModule mod_rewrite.c>
    RewriteCond %{REQUEST_URI} ^/specific/url/
    RewriteCond %{QUERY_STRING} key=value
    RewriteRule (.*) /path/ [R=301,L]

Or, you could redirect the URI and grab the %{QUERY_STRING} to make it a new path for the 301 in the RewriteRule.

RewriteCond %{REQUEST_URI} ^/specific/url/
RewriteCond %{QUERY_STRING} ^intDepartmentId=(.*)$
#  intDepartmentId is the only variable so the
#  query string starts with int... ^ denotes start
#  and the value (.*) is everything after the = ... $ denotes to the end
RewriteRule HTTP://example.com/path/%1 [R=301,L]
# resulting in 301 to /path/value_of_intDepartmentId

If you have FTPS or SSH you should have access to the .htaccess file? And that appears to be available according to Odoo website?

If the redirect is being done in a old-site.conf the redirects can be placed in the conf instead of the .htaccess, which may be what is happening? and the translation of don't have access, (which .htaccess file) Old one? ... Where is the redirect being generated?

And yes you can redirect everything in the intDepartmentID to a new URL, which might be your use case?

# match everything with a query string of intDepartmentID
RewriteCond %{QUERY_STRING} ^intDepartmentId=(.*)$
RewriteRule HTTP://example.com/path/%1 [R=301,L]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.