문제

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