NameSilo

301 redirect/rewrite question (Htaccess)

Spaceship Spaceship
Watch

Miyavi

o-re-sa-maVIP Member
Impact
41
On one of my message boards, my forum is installed on the root directory and thus thread URLs are set up like this:
http://www.mysite.com/thread-100.html

However, I would like to move my forum to /forum/ and thus have my URLs become http://www.mysite.com/forum/thread-100.html

What sort of 301 wildcard redirect/rewrite can I use to accomplish this with my .htaccess file? Something that will change /thread-*.html to /forum/thread-*.html

Thanks!
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
Unstoppable DomainsUnstoppable Domains
Can anyone help with this?
 
0
•••
Are you moving the files and changing the settings for the message board too?

Here's what you'll need for redirecting old URLs to the new ones:

Code:
RewriteRule ^thread-([0-9]+)\.html$ /forums/thread-$1.html [R=301,L]
 
0
•••
Yes, I will be moving the files and changing the settings for the message board as well.

Thank you for posting that by the way; I never thanked you before. :tu:

If I would like to use a subdomain instead, how would I change that rewrite code? For example, if I want all http://www.mysite.com/thread-100.html URLs to become http://forum.mysite.com/thread-100.html

Second question/situation:
I plan on changing domain names soon. If I don't implement the redirect until after changing my domain name, how would the code change? Would I need two redirects? For example, if I want all http://www.mysite.com/thread-100.html URLS to become http://forum.myNEWsite.com/thread-100.html, which RewriteRule(s) should I use?

Third question/situation:
If I decide not to use a subdomain, how would the code change if using the same situation from my second question/situation? In other words, if I want all http://www.mysite.com/thread-100.html URLS to become http://www.myNEWsite.com/forum/thread-100.html, which RewriteRule(s) should I use?

Thank you!

Major thanks and rep coming to anyone who can help.
 
Last edited:
0
•••
In either case, just change the substitution URL.

For 2)
Code:
RewriteRule ^thread-([0-9]+)\.html$ http://forum.myNEWsite.com/thread-$1.html [R=301,L]

for 3)
Code:
RewriteRule ^thread-([0-9]+)\.html$ http://www.myNEWsite.com/forum/thread-$1.html [R=301,L]
 
0
•••
why not make a forum folder and move the files there? you can set the settings to the new location when youre finished moving...
 
0
•••
Dynadot — .com Registration $8.99Dynadot — .com Registration $8.99

We're social

Unstoppable Domains
Domain Recover
DomainEasy — Live Options
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back