How to redirect a webpage with .htaccess
I have this code in my htaccess but it is not working.
RewriteEngine on RewriteBase /
RewriteRule viewtopic\.php?t=([^/]+)$
http://newdomain.com/viewtopic.php?t=$1
How to redirect the page of viewtopic.php?t=1 to viewtop开发者_如何转开发ic.php?t=2000 to my new domain?
In addition to Daniel Gehriger's solution, add [L,R=301]
at the end of the line. This will make Apache send the 301 Page Moved code to your client, informing it that the page has indeed moved permanently. This will cause search engines, RSS readers etc update their links (if they are clever enough).
You need to escape the .
and ?
in the pattern.
RewriteEngine on
RewriteBase /
RewriteRule viewtopic\.php\?t=([^/]+)$ http://newdomain.com/viewtopic.php?t=$1 [L,R=permanent]
just incase someone here have problem as mine, i use this code to redirect an html page to a sub domain:
RewriteEngine on
RewriteBase /
RewriteRule sharecrypt.html http://cryptool.sharepirate.com [L,R=301]
精彩评论