Redirect 301 Static Page with Parameters to Static Page

Joined
Nov 11, 2022
Messages
2
Reaction score
0
I need to do a simple static single redirection from one page to another. The problem is that the URL of the page to be redirected or of both pages contain specials characters ("?", "%", "$" etc.).

I have do this redirection here:

from

confindustria.vr.it/confindustria/verona/board.nsf/pages/lavoro?opendocument

to

verona-www.neispa.com/hub/confindustria/verona/gate.nsf/homema?openform&restricttocategory=Lavoro%20e%20previdenza

I thought it was enough just to do like this:

Code:
RewriteCond %{THE_REQUEST} ^confindustria/verona/board.nsf/pages/lavoro$
RewriteCond %{QUERY_STRING} ^opendocument$
RewriteRule ^(.*)$ https://verona-www.neispa.com/hub/confindustria/verona/gate.nsf/homema?openform&restricttocategory=Lavoro%20e%20previdenza [R=301,L]

But I see it doesn't work.

What should I do?
 
Joined
Mar 5, 2023
Messages
36
Reaction score
12
The RewriteCond directive you've used checks only for the path and query string of the requested URL, not the full URL with the protocol and domain name. So you need to modify your RewriteCond to include the full URL.

Try changing your code to the following:

Ruby:
RewriteCond %{HTTP_HOST}%{REQUEST_URI} ^confindustria\.vr\.it/confindustria/verona/board\.nsf/pages/lavoro\?opendocument$
RewriteRule ^(.*)$ https://verona-www.neispa.com/hub/confindustria/verona/gate.nsf/homema?openform&restricttocategory=Lavoro%20e%20previdenza [R=301,L]

This should match the full URL http://confindustria.vr.it/confindustria/verona/board.nsf/pages/lavoro?opendocument and redirect to https://verona-www.neispa.com/hub/c...enform&restricttocategory=Lavoro e previdenza.

Note that I've also added the escape character '' before the special characters in the RewriteCond pattern. This is necessary because some characters like '.' and '?' have special meanings in regular expressions and need to be escaped to be matched literally.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,707
Messages
2,569,343
Members
44,635
Latest member
Matt231

Latest Threads

Top