• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 1.3 Help with a couple redirects?

kontrabass

Well-known member
#1
Can someone help me finish out my vbulletin 3.x -> xenforo redirects? In my httpd.conf I have the following which work great for all threads posts and users.

Code:
RewriteRule ^f[0-9]+/.+-([0-9]+)/$ /threads/$1/ [R=301,L]

RewriteRule ^f([0-9]+)/$ /forums/$1/ [R=301,L]

RewriteCond %{QUERY_STRING} (^|\?)u=([0-9]+)$

RewriteRule ^member\.php$ /members/%2/? [R=301,L]
There are just a few URL's that I'd like to redirect one-by-one but I can't seem to get the syntax correct in my httpd.conf. Specifically these that are top in our search results:

http://www.talkbass.com/forum -redirected to-> http://www.talkbass.com/forums/

http://www.talkbass.com/forum/f45/ -redirected to-> http://www.talkbass.com/categories/bass-guitar.45/

http://www.talkbass.com/forum/f44/ -redirected to-> http://www.talkbass.com/categories/double-bass.245/


Thanks!!!!
 
Last edited:

Jake Bunce

XenForo moderator
Staff member
#2
Remove the old /forum directory (or rename) and add these rules to the top of the .htaccess file in your web root:

Code:
RewriteRule ^forum$ /forums/ [R=301,L]
RewriteRule ^forum/f45/$ /categories/bass-guitar.45/ [R=301,L]
RewriteRule ^forum/f44/$ /categories/double-bass.245/ [R=301,L]
 

kontrabass

Well-known member
#3
Thanks Jake, I seem to have myself in a bit of a bind here. Here's my web root .htaccess:

Code:
#       Mod_security can interfere with uploading of content such as attachments. If you

#       cannot attach files, remove the "#" from the lines below.

#<IfModule mod_security.c>

#       SecFilterEngine Off

#       SecFilterScanPOST Off

#</IfModule>

ErrorDocument 401 default

ErrorDocument 403 default

ErrorDocument 404 default

ErrorDocument 500 default



<IfModule mod_rewrite.c>

        RewriteEngine On



RewriteRule ^forum$ /forums/ [R=301,L]

RewriteRule ^forum/f45/$ /categories/bass-guitar.45/ [R=301,L]

RewriteRule ^forum/f44/$ /categories/double-bass.245/ [R=301,L]



RewriteRule ^f[0-9]+/.+-([0-9]+)/$ /threads/$1/ [R=301,L]

RewriteRule ^f([0-9]+)/$ /forums/$1/ [R=301,L]

RewriteCond %{QUERY_STRING} (^|\?)u=([0-9]+)$

RewriteRule ^member\.php$ /members/%2/? [R=301,L]









        #       If you are having problems with the rewrite rules, remove the "#" from the

        #       line that begins "RewriteBase" below. You will also have to change the path

        #       of the rewrite to reflect the path to your XenForo installation.

        #RewriteBase /xenforo



        #       This line may be needed to enable WebDAV editing with PHP as a CGI.

        #RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]



        RewriteCond %{REQUEST_FILENAME} -f [OR]

        RewriteCond %{REQUEST_FILENAME} -l [OR]

        RewriteCond %{REQUEST_FILENAME} -d

        RewriteRule ^.*$ - [NC,L]

        RewriteRule ^(data/|js/|styles/|install/|favicon\.ico|crossdomain\.xml|robots\.txt) - [NC,L]

        RewriteRule ^.*$ index.php [NC,L]

</IfModule>
Ok so it appears if I MOVE the old /forum directory, the threads/posts/user redirects don't work, but the new directives you gave me DO work. If I LEAVE the old /forum directory, the threads/posts/user redirects work but the new directives you gave me don't.

Blerg. :(
 

kontrabass

Well-known member
#4
There must be a way to modify these:

Code:
RewriteRule ^f[0-9]+/.+-([0-9]+)/$ /threads/$1/ [R=301,L]

RewriteRule ^f([0-9]+)/$ /forums/$1/ [R=301,L]

RewriteCond %{QUERY_STRING} (^|\?)u=([0-9]+)$

RewriteRule ^member\.php$ /members/%2/? [R=301,L]
so that they work when /forum is moved to /forum_old

Thanks for your help Jake!
 

Jake Bunce

XenForo moderator
Staff member
#5
That's fine. Keep your /forum directory as is. Then add these rules to the top of the .htaccess file in the /forum directory:

Code:
RewriteRule ^$ /forums/ [R=301,L]
RewriteRule ^f45/$ /categories/bass-guitar.45/ [R=301,L]
RewriteRule ^f44/$ /categories/double-bass.245/ [R=301,L]
 

kontrabass

Well-known member
#6
That's fine. Keep your /forum directory as is. Then add these rules to the top of the .htaccess file in the /forum directory:

Code:
RewriteRule ^$ /forums/ [R=301,L]
RewriteRule ^f45/$ /categories/bass-guitar.45/ [R=301,L]
RewriteRule ^f44/$ /categories/double-bass.245/ [R=301,L]
Ok, I did this, but as soon as I do, these redirects which are in the xf root .htaccess (web root) stop working:

Code:
RewriteRule ^f[0-9]+/.+-([0-9]+)/$ /threads/$1/ [R=301,L]

RewriteRule ^f([0-9]+)/$ /forums/$1/ [R=301,L]

RewriteCond %{QUERY_STRING} (^|\?)u=([0-9]+)$

RewriteRule ^member\.php$ /members/%2/? [R=301,L]
And these are obviously more important :)

Sorry to be a pain Jake, thanks again!
 

Jake Bunce

XenForo moderator
Staff member
#7
There can be context here. I have added RewriteEngine On which is sometimes needed.

Add these rules to the top of the .htaccess file in the /forum directory:

Code:
RewriteEngine On

RewriteRule ^$ /forums/ [R=301,L]
RewriteRule ^f45/$ /categories/bass-guitar.45/ [R=301,L]
RewriteRule ^f44/$ /categories/double-bass.245/ [R=301,L]
 

kontrabass

Well-known member
#8
Yeah, that's what I had in /forum, with the RewriteEngine line too.

Code:
#RewriteEngine On

#RewriteRule ^$ / [R=301,L]

#RewriteRule ^f45/$ /categories/bass-guitar.45/ [R=301,L]

#RewriteRule ^f44/$ /categories/double-bass.245/ [R=301,L]
It works, but it breaks the more important rewrites in the root .htaccess.

Oh well. I added a php redirect to /forum/index.php so at least that one's working. The others, google can find again :)