3

I have my .htaccess file in the base directory of the installation of XenForo. When I enable SEO Friendly URLs, it returns error 404 only on the forums and members pages.

htaccess file:

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

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

when looking at the links when SEO Friendly URLs is enabled/disabled the index.php? is gone, which it's supposed to do but it can't seem to find the forums...

  • "only on the forums and members pages" - so the "friendly URLs" (without the index.php) work OK on other pages? (You seem to have disabled friendly URLs across your whole site at the moment? ...I'm wondering why you are linking to it?) – MrWhite Dec 19 '17 at 1:18
  • I have members trying to figure out why my servers are down, can't access it without the forums. I'll enable it now, won't do much good. – diamondpumpkin Dec 19 '17 at 1:22
  • Ah, so it's not "only on the forums and members pages" - it's on all friendly URLs. (?) Remove the <IfModule mod_rewrite.c> wrapper. Any errors? – MrWhite Dec 19 '17 at 1:30
  • None in apache or Xenforo's logging. – diamondpumpkin Dec 19 '17 at 1:38
  • Is FollowSymLinks enabled? Try adding Options +FollowSymLinks to the start of your .htaccess file. – MrWhite Dec 19 '17 at 1:39
1

Apparently not, no error whatsoever.

It seems that .htaccess files are not allowed/enabled on your server, since adding some random text to the file produces no error. (You would expect to see a 500 Internal Server Error otherwise.)

You need to set AllowOverride All (or something more restrictive like AllowOverride FileInfo - enough for mod_rewrite) in your server config (<Directory> container) that covers the document root directory.

However, if you have access to the server config then you can do all of this in the server config and not use .htaccess at all (recommended).

Reference:
https://httpd.apache.org/docs/2.4/mod/core.html#allowoverride


UPDATE: And then if it's still not working, repeat the checks as mentioned in comments above:

  • Is mod_rewrite enabled? Remove the <IfModule mod_rewrite.c> wrapper - do you get an error? If mod_rewrite is not enabled then expect to see a 500 Internal Server Error (your error log should contain the specific details of the error). You need to enable mod_rewrite and restart Apache.
  • Is FollowSymLinks (or SymLimksIfOwnerMatch) enabled? This is required for mod_rewrite to work. Add Options +FollowSymLinks at the top of your .htaccess file.

If you are still seeing an Apache generated 404 message then then "something else" is going on, since the URL is not being rewritten. (Your .htaccess file looks "OK".)

If you are seeing a 404 generated from your framework (XenForo) then the problem is with your application.

  • I have enabled htaccess files, the file with random text now produces errors. I have loaded the backup file I made before making any changes. I am still unable to access the forums and members pages. – diamondpumpkin Dec 19 '17 at 2:07
  • You have an issue with XEN then, not mod_rewrite. – Simon Hayter Dec 19 '17 at 8:13
  • Repeat the checks as mentioned above (in comments). Are you still getting an Apache generated 404 message (it appeared to be when I checked a short while ago) - this would imply you still have an Apache config issue. If, however, you are getting a 404 generated from your application then the problem is now with your application (as Simon suggests). I've updated my answer. – MrWhite Dec 19 '17 at 10:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.