XF 2.1 Help with .htaccess redirects

samh004

Member
We took the path of vB4 > 1.5 > 2.1, with 18 months on 1.5 where redirects from old vBulletin links were working great. Since upgrading to 2.1 though they have all stopped working. I was under the impression there should be no reason for these rules to stop working, but they mysteriously have. I understand the principles behind "mod_rewrite" but I am far from an expert and so far my attempts to fix the problem on my own have ended with broken links or a broken installation. Hoping someone can point me in the right direction.

An example of a previous vBulletin link is as follows: http://www.example.com/community/trip-reports-and-trip-photos/thread-title-12345.html

Our .htaccess file was setup with a long list of repeating redirects for different forums, and I'll include a snippet of the 5 lines from the forum that relates to the link above, below. In total, 410 lines comprising 82 forums... there's probably a more succinct way of redirecting old links.

Apache config:
<IfModule mod_rewrite.c>
    RewriteEngine On

    #    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 /community

    RewriteCond %{SERVER_PORT} 80
    RewriteRule ^(.*)$ https://www.example.com/community/$1 [R,L]

    #    This line may be needed to enable WebDAV editing with PHP as a CGI.
    #RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

RewriteRule ^trip-reports-and-trip-photos/(.*?)-([0-9]+)-new-post.html showthread.php?t=$2
RewriteRule ^trip-reports-and-trip-photos/(.*?)-([0-9]+).html showthread.php?t=$2
RewriteRule ^trip-reports-and-trip-photos/index([0-9]+)\.html forumdisplay.php?f=92&page=$1 [NC,L]
RewriteRule ^trip-reports-and-trip-photos forumdisplay.php?f=92 [NC,L]
RewriteRule ^trip-reports-and-trip-photos/ forumdisplay.php?f=92 [NC,L]


    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>

When clicking links currently, the URL becomes https://www.example.com/community/trip-reports-and-trip-photos/install/install/install/install/install/install/install/install/install/install/install/install/install/install/install/install/install/install/install/index.php
 
Why aren't you using the Xenforo vBulletin redirect addon? It works very well and you don't need to worry about the hassle of debugging all those rewrite rules.

 
Why aren't you using the Xenforo vBulletin redirect addon? It works very well and you don't need to worry about the hassle of debugging all those rewrite rules.

Tried it but couldn't work out which was the correct "vBulletin import log table" and after trying some obvious choices I'm starting to think this table does not exist in my database. Annoying if it's not there, but it was working fine under 1.5 through the "htaccess" file.
 
I agree with djbaxter, the redirect add-on is very good. Staff devs were very helpful getting me sorted.

I always thought that table had to existing compulsory when you import. I may be wrong. However I suggest you open a support ticket because trying to do it via htaccess alone will be a nightmare waiting to happen.
 
Last edited:
My website is not loading, the htaccess changed into this
I don't know why and what to do ?

# 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 405 default
ErrorDocument 406 default
ErrorDocument 500 default
ErrorDocument 501 default
ErrorDocument 503 default

<IfModule mod_rewrite.c>
RewriteEngine On

# 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 workaround HTTP Basic auth issues when using 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>
AddHandler application/x-httpd-php72 .php .php5 .php4 .php3





link
 
1. what do you mean your website is not loading? are you getting a server 500 error?

2. what version of Xenforo and what version of PHP are you running?

3. your server doesn't seem to know what to do with a PHP file - open a ticket with your hosting server.

4. what do you mean by "the htaccess file changed into this"? what has changed in that file?

5. what did you use to edit this file? Hint: NEVER USE NOTEPAD!

6. is your server running mod_security? If so, you need to uncomment four lines in that section:
Apache config:
# 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>

7. Try uncommenting this line: change #RewriteBase /xenforo to RewriteBase /xenforo
 
Back
Top Bottom