XF 2.2 Redirect Issues

xelA

Member
I moved my XF forum from root to '/community/' subdirectory.

htaccess file in root directory showed:

Code:
RewriteEngine On
RewriteRule ^threads/(.*)$ community/threads/$1
RewriteRule ^posts/(.*)$ community/posts/$1
RewriteRule ^media/(.*)$ community/media/$1
RewriteRule ^whats-new/(.*)$ community/whats-new/$1
RewriteRule ^members/(.*)$ community/members/$1
RewriteRule ^help/(.*)$ community/help/$1
RewriteRule ^help/terms/(.*)$ community/help/terms/$1
RewriteRule ^help/privacy-policy/(.*)$ community/help/privacy-policy/$1
RewriteRule ^forums/(.*)$ community/forums/$1[R=301,NC,L]

Everything was working fine, until I installed Wordpress in the root directory. The new htaccess file in root shows:

Code:
# BEGIN WordPress
# The directives (lines) between "BEGIN WordPress" and "END WordPress" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

RewriteEngine On
RewriteRule ^threads/(.*)$ community/threads/$1
RewriteRule ^posts/(.*)$ community/posts/$1
RewriteRule ^media/(.*)$ community/media/$1
RewriteRule ^whats-new/(.*)$ community/whats-new/$1
RewriteRule ^members/(.*)$ community/members/$1
RewriteRule ^help/(.*)$ community/help/$1
RewriteRule ^help/terms/(.*)$ community/help/terms/$1
RewriteRule ^help/privacy-policy/(.*)$ community/help/privacy-policy/$1
RewriteRule ^forums/(.*)$ community/forums/$1[R=301,NC,L]

Now the old XF links doesn't get redirected to the new ones (/community/).

What could be the issue and how do I fix?
 
Hi Brogran,

I tried that, cleared my browser's cache (just in case), and it still doesn't work.

For some reason, the custom rewrites are ignored because when I click on my old XF links in SERPS, it doesn't get redirected to the new ones.

When I remove the WP rewrites and leave my custom ones there, it works again.

Any other suggestions?
 
Did you tried ?

Code:
# BEGIN WordPress
# The directives (lines) between "BEGIN WordPress" and "END WordPress" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

<IfModule mod_rewrite.c>
RewriteRule ^threads/(.*)$ community/threads/$1
RewriteRule ^posts/(.*)$ community/posts/$1
RewriteRule ^media/(.*)$ community/media/$1
RewriteRule ^whats-new/(.*)$ community/whats-new/$1
RewriteRule ^members/(.*)$ community/members/$1
RewriteRule ^help/(.*)$ community/help/$1
RewriteRule ^help/terms/(.*)$ community/help/terms/$1
RewriteRule ^help/privacy-policy/(.*)$ community/help/privacy-policy/$1
RewriteRule ^forums/(.*)$ community/forums/$1[R=301,NC,L]
</IfModule>
 
Last edited:
I don't use .htaccess but have you checked to see if there is one existing in the /community subdirectory?
You said you "moved" it.... so if it was a file copy over, you may have copied the original one into it and it may be interfering?
 
Hi Tracy,

When my XF was in root, he htaccess was the default XF rewrite rules as seen here:

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 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>

When I moved it to the '/community' subdirectory, the htaccess was the same as above.

I added the new rewrite rules and placed it in the root directory:

Code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^threads/(.*)$ community/threads/$1
RewriteRule ^posts/(.*)$ community/posts/$1
RewriteRule ^media/(.*)$ community/media/$1
RewriteRule ^whats-new/(.*)$ community/whats-new/$1
RewriteRule ^members/(.*)$ community/members/$1
RewriteRule ^help/(.*)$ community/help/$1
RewriteRule ^help/terms/(.*)$ community/help/terms/$1
RewriteRule ^help/privacy-policy/(.*)$ community/help/privacy-policy/$1
RewriteRule ^forums/(.*)$ community/forums/$1[R=301,NC,L]
</IfModule>

All was working fine, that is until I installed Wordpress and their rewrite rules were added to the root's htaccess, then the XF redirects stopped working. For some reason, WP is interfering and causing '/community/forums' to go to 'forums' for example.

The new root htaccess now looks like this:

Code:
# MY CUSTOM REWRITE
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^threads/(.*)$ community/threads/$1
RewriteRule ^posts/(.*)$ community/posts/$1
RewriteRule ^media/(.*)$ community/media/$1
RewriteRule ^whats-new/(.*)$ community/whats-new/$1
RewriteRule ^members/(.*)$ community/members/$1
RewriteRule ^help/(.*)$ community/help/$1
RewriteRule ^help/terms/(.*)$ community/help/terms/$1
RewriteRule ^help/privacy-policy/(.*)$ community/help/privacy-policy/$1
RewriteRule ^forums/(.*)$ community/forums/$1[R=301,NC,L]
</IfModule>

# BEGIN LSCACHE
## LITESPEED WP CACHE PLUGIN - Do not edit the contents of this block! ##
<IfModule LiteSpeed>
RewriteEngine on
CacheLookup on
RewriteRule .* - [E=Cache-Control:no-autoflush]
RewriteRule \.litespeed_conf\.dat - [F,L]

### marker CACHE RESOURCE start ###
RewriteRule wp-content/.*/[^/]*(responsive|css|js|dynamic|loader|fonts)\.php - [E=cache-control:max-age=3600]
### marker CACHE RESOURCE end ###

### marker FAVICON start ###
RewriteRule favicon\.ico$ - [E=cache-control:max-age=86400]
### marker FAVICON end ###

### marker DROPQS start ###
CacheKeyModify -qs:fbclid
CacheKeyModify -qs:gclid
CacheKeyModify -qs:utm*
CacheKeyModify -qs:_ga
### marker DROPQS end ###
</IfModule>

## LITESPEED WP CACHE PLUGIN - Do not edit the contents of this block! ##
# END LSCACHE
# BEGIN NON_LSCACHE
## LITESPEED WP CACHE PLUGIN - Do not edit the contents of this block! ##
## LITESPEED WP CACHE PLUGIN - Do not edit the contents of this block! ##
# END NON_LSCACHE

# BEGIN WordPress
# The directives (lines) between "BEGIN WordPress" and "END WordPress" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

Not sure what's going on there.
 
Not familiar with LightSpeed.... but by chance did you try restarting it in case it does any caching (it shouldn't)?
Did you check to see if you had an .htaccess in the /community directory, and if so, rename it?
 
I'm on a shared hosting plan, so I don't think I can restart Apache. I don't think it's a cache issue because when I only leave my custom rewrite rules and save, everything works again.

Yes, I tried renaming the htaccess file in the '/community' subdirectory but no dice. All I get is the 404 WP error page.
 
Last edited:
Okay. The following rewrite rules (in root's htaccess), which I replaced with the old one in my first post, did the trick and now WordPress and XenForo are working without 404 issues.

Code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(forums|threads|posts|whats-new|media|members|help|misc)/(.*)$ /community/$1/$2 [NC,L,R=301]
</IfModule>

Thanks again to those who tried to help. I appreciate it. :)
 
Last edited:
Top Bottom