Domanda

I need to 301 redirect one URL to another. Now I have this rule in .htaccess

RewriteRule /forum/viewtopic.php?f=65&t=6 /page/name-of-the-page [R=301]

RewriteRule /forum/viewtopic.php?f=30&t=5 /page/another-name-of-the-page [R=301]

But it doesnt work at all. Could please anybody help me with that?

Thank you very much in advance!

È stato utile?

Soluzione

You cant match query string using RewriteRule. Use it like this:

RewriteEngine On

RewriteCond %{QUERY_STRING} ^f=65&t=6$
RewriteRule ^forum/viewtopic\.php$ /page/name-of-the-page? [R=301,L]

RewriteCond %{QUERY_STRING} ^f=30&t=5$
RewriteRule ^forum/viewtopic\.php$ /page/another-name-of-the-page? [R=301,L]

? in the end is used to strip-off any existing query string.

Altri suggerimenti

RewriteRule /forum/viewtopic.php?f=30&t=5 /page/another-name-of-the-page [R=301]
RewriteRule /forum/viewtopic.php?f=65&t=6 /page/name-of-the-page [R=301]

just reverse the order and it should work!

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top