XF 1.2 Possible htaccess problems, site breaks switching to Apache

cmeinck

Well-known member
A few weeks back, I asked my host to switch from Litespeed back to Apache. This due to the issues affecting CSS breaking and Litespeed seemingly slow to provide a patch. In any event, when my host did the move, the site completely broke. Nasty 500 errors. They blamed it on my .htaccess, so now I'm taking a good hard look to see if there are some lingering issues there that I should correct. Here's what I have as of now:

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 [^/]+/.+-([\d]+)-([\d]+).html showthread.php?t=$1&page=$2 [NC,L]
RewriteRule [^/]+/.+-([\d]+).html showthread.php?t=$1 [NC,L]
   
    RewriteCond %{HTTP_HOST} !^www\.mysite\.com
    RewriteRule (.*) http://www.mysite.com/forum/$1 [L,R=301]
   
    #    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>
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -l [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^.*$ - [NC,L]
    RewriteRule ^(data|js|styles|install) - [NC,L]
    RewriteRule ^.*$ index.php [NC,L]

After this I have numerous 301 directs, that look like this:
Redirect 301 /forum/category http://www.mysite.com/forum/forums/category

Looking at the default XF htaccess, I'm not sure if this piece is a duplicate of sorts.

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^(data|js|styles|install) - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

Should I have my vbSEO rewrites at the top? Finally, is my code for redirecting to the www version of my forums correct?

Anything here that might be messing with Apache, but would cause it to work with Litespeed?
 
Yes, everything after </IfModule> is a duplicate and can be removed.

I see nothing obviously wrong with your .htaccess file.

You should contact your host about the 500 errors. The log files on the server itself should contain more information about the error.
 
Thanks. I've been cleaning up my .htaccess before going back to them. They won't support .htaccess and blamed it on my file. I want to be sure it's working properly and everything is in working order before I reach out to them.

In Google Webmasters, I had been seeing a number of odd 404s that were not handled by my redirect. The are formed like this:

Redirect 301 /forum/category/mms-is-out-right-now-54470-post514419.html

I have about 200 or so of these. If I strip the -post###, my redirect works. Any suggestions or ideas on a redirect that would handle the stripping of -post###.

So, this URL:
/forum/category/mms-is-out-right-now-54470-post514419.html
becomes
http://www.mysite.com/forum/category/mms-is-out-right-now.54470.html

That would further trim down my htaccess.
 
Found a few hundred more individual 301 redirects. Any help with shorter rewrite would be awesome and greatly appreciated. Below are samples of how I've set up redirects.

Code:
Redirect 301 /2009/5/20/article-title/ http://www.mysite.com/article-title/2009/05/20/

On the one below, I have multiple categories, but the rest of the URL remains the same.
Code:
/news/categorya/article-title-20080708539/ http://www.mysite.com/article-title/2008/07/08/

Redirect 301 /news/categoryb/different-article-2007012793/ http://www.mysite.com/different-article/2007/01/27/

Code:
Redirect 301 /blog/article-title-20080214438/ http://www.mysite.com/article-title/2008/02/14/

Code:
Redirect 301 /articles/2008/10/1/article-title/ http://www.mysite.com/article-title/2008/10/01/

I realize plenty of this is outside the scope of XF, but I've found this community to be the most helpful and often most informed on this sort of stuff. Hoping to trim down my 700 line plus htaccess files. These large redirect files cannot be good for a site and also make it easier for mistakes to get by...

Thanks!
 
My lengthy site audit is almost coming to a close. A tiring, but hopefully worthwhile process after a year of continuously declining traffic. When I spider my site for broken links, I'm getting a 404 for http://www.mysite.com/forum/./

This is an odd URL, so I looked for any links to that page, thinking maybe it was a misformed URL somewhere.

When I look at the path, it's showing me the anchor text for where these errors are coming. It will show a forum category url, perfectly formed and these URLS work perfectly fine when browsing. For example, http://www.mysite.com/forum/#software.29

The path shows the redirect adding a trailing slash and final 404 at http://www.mysite.com/forum/./

Using the same software, I checked Xenforo and no such error. Here's my .htaccess. There are two lines for my vBSEO redirects which were created at Geekpoint. The other is redirecting to non-www pages to www.

Could this be a Litespeed/Apache issue?

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 [^/]+/.+-([\d]+)-([\d]+).html showthread.php?t=$1&page=$2 [NC,L]
RewriteRule [^/]+/.+-([\d]+).html showthread.php?t=$1 [NC,L]
   
    RewriteCond %{HTTP_HOST} ^mysite\.com$ [NC]
        RewriteRule ^(.*)$ http://www.mysite.com/forum/$1 [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>

Does anything look out of place? I might test the removal of my custom vBSEO rewrites on a different site, since removing it would create all sorts of broken URLs from my vBulletin past.

Thanks in advance.
 
After looking at my sites, the problem does not appear on pre 1.2 XF sites. I did a more comprehensive crawl of XF and it's happening here as well. I submitted a ticket regarding the issue.
 
Back
Top Bottom