Вопрос

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!

Это было полезно?

Решение

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.

Другие советы

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!

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top