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

XF 1.4 Can't enable mod_rewrite in apache on CentOS

Discussion in 'Troubleshooting and Problems' started by EpicDinosaurz, Feb 17, 2015.

  1. EpicDinosaurz

    EpicDinosaurz Member

    Hey guys. Normally I don't have issues at all enabling mod_rewrite in Apache on my CentOS server, but this time I just can't seem to get it to work. I am trying to enable it for my newly purchased Xenforo license.

    Here's my .htaccess in /var/www/html
     #    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
    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 mumausprison.com/
        #    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]
    and here is my apache conf.d file in /etc/httpd/conf/httpd.conf

    (Used pastebin because it'd take up too much space in here, haha)
  2. Mike

    Mike XenForo Developer Staff Member

    It's usually an AllowOverride issue. I see an area that appears to try to change it, but it's also using these weird smart quotes so it may not be doing what you expect (and I also don't know if that's where your web root is).
  3. Kuma

    Kuma Active Member

    If you have access to the sites configuration file, it would be best to list the rewrite and other overrides you would normally put into the .htaccess in the vhost file.
    If you cannot do that for some reason, make sure to modify the AllowOverrides setting as Mike pointed out in the httpd.conf / vhosts file(s). You would want to set your specific requirements, but if you are unsure of those you can just do

    AllowOverride All
    Not really recommended but do-able.

    Edit, as a quick note your rewrite base should read
    RewriteBase /
    RewriteBase /folder/xf/sits/in/
    You would not put your domain in front of the /
    Last edited: Feb 17, 2015
  4. EpicDinosaurz

    EpicDinosaurz Member

    Hey @Mike I tried changing the quotes to normal ones, strange enough, when I change it to the correct quotes I get 500 internal server error. Also, the web root is /var/www/html.
  5. Mike

    Mike XenForo Developer Staff Member

    You can probably just take out the quotes (see starting from line 302).
  6. EpicDinosaurz

    EpicDinosaurz Member

    Tried removing quotes from
    <Directory “/var/www/html“>
        Options Indexes FollowSymLinks Includes ExecCGI
        AllowOverride All
        Order allow,deny
        Allow from all
    in the apache config, got 500 internal server error. Appears only those weird quotes are working :/

    Anybody know a fix?
  7. Mike

    Mike XenForo Developer Staff Member

    You'll need to look in the Apache error log to get a more specific error message.

Share This Page