Anyone know how to redirect with .htaccess
all the URLs of the form:
www.example.com/showthread.php(any content)
towww.example.com/forum/showthread.php(same content)
I just want it to happen in this type of URL, there are other URL that I do not want to be modified.
I assume
(any content)
is referring to a query string (starting with a?
). You can do something like the following using mod_rewrite in your root.htaccess
file.This would need to go near the top of the
.htaccess
file.This will redirect a URL of the form
/showthread.php?<something>
to/forum/showthread.php?<something>
.$0
is a backreference to the entire URL-path that is matched. The query string is automatically copied through to the target URL.This is a 302 (temporary) redirect. Change to a 301 if this intended to be permanent - but only after you have confirmed it's working OK.