Search code examples
.htaccessvbulletinmod-alias

Need Help on htaccess Redirection


Need help to make htaccess. I use 2 domains: abc.domain1.com and domain2.com. the htaccess will be in domain2.com. i want to use it for vbulletin shorturl.

The idea are;

  1. redirect domain2.com/[numbers] (example= domain2.com/678) to abc.domain1.com/threads/[same numbers] (example = abc.domain1.com/threads/678)

  2. redirect domain2.com/a[numbers] (example= domain2.com/a1234) to abc.domain1.com/forums/[same numbers] (example = abc.domain1.com/forums/1234)

i tried for the case 1, is works with:

RedirectMatch ^/(.*) https://abc.domain1.com/threads/$1

but it doesn't work for case 2. i tried

RedirectMatch ^/f(.*) https://abc.domain1.com/forums/$1

but it gives me /threads/f[numbers]


Solution

  • The problem is that /f1234 matches ^/(.*) and it's being redirected to https://abc.domain1.com/threads/f1234.

    Reverse the RedirectMatch lines, so that the more specific redirect is toward the top, and the "catch all" is at the very bottom:

    RedirectMatch ^/f(.*) https://abc.domain1.com/forums/$1
    RedirectMatch ^/(.*) https://abc.domain1.com/threads/$1