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

XF 1.5 htaccess, xenForo, WordPress and parked domains

Discussion in 'Troubleshooting and Problems' started by Harness Media, Jun 17, 2016.

  1. Harness Media

    Harness Media Member

    I have a weird problem and I can't seem to find anyone that knows why it's a problem.

    I have a website at http://rplstoday.com -- WordPress is installed in the root and xenForo is installed at /community. I have another domain pointing there, but I want everything to point at their respective rplstoday.com locations. That is:

    beerleg.com --> rplstoday.com
    beerleg.com/community --> rplstoday.com/community
    beerleg.com/community/blahblah --> rplstoday.com/community/blahblah

    Here is what I currently have in .htaccess in root:
    Code:
    RewriteCond %{HTTP_HOST} ^beerleg.com$ [OR]
    RewriteCond %{HTTP_HOST} ^www.beerleg.com$
    RewriteRule (.*)$ http://rplstoday.com/$1 [R=301,L]
    The default xenForo .htaccess is untouched.

    However, here's what really happens:

    beerleg.com --> rplstoday.com
    beerleg.com/community --> beerleg.com/community
    beerleg.com/community/blahblah --> beerleg.com/community/blahblah

    As you can see, the rewrite only occurs for the base domain, but not when going to any internal URLs. I suspect that xenForo may be undoing some of this, but my lack of knowledge (and inability to find fixes via Google) has me stumped. Any ideas?
     
  2. Mike

    Mike XenForo Developer Staff Member

    You need to add those rules to the .htaccess file in /community too. Because of that file, the rules in the root of the domain aren't being called.
     
  3. Harness Media

    Harness Media Member

    Thanks for the info, Mike. However, it didn't make any difference. I'm totally stumped.
     
  4. Mike

    Mike XenForo Developer Staff Member

    Can you show the full /community .htaccess? Where you put the lines you're adding is significant. It needs to be above XF's existing rewrites.
     
  5. Harness Media

    Harness Media Member

    The full root .htaccess:
    Code:
    <IfModule mod_rewrite.c>
    Options +FollowSymLinks
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^beerleg.com$ [OR]
    RewriteCond %{HTTP_HOST} ^www.beerleg.com$
    RewriteRule (.*)$ http://rplstoday.com/$1 [R=301,L]
    </IfModule>
    
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    # add a trailing slash to /wp-admin
    RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
    RewriteRule . index.php [L]
    </IfModule>
    # END WordPress
    The full /community .htaccess:
    Code:
    <ifModule mod_headers.c>
      Header set Connection keep-alive
    </ifModule>
    
    <IfModule mod_mime.c>
        AddType text/css .css
        AddType application/x-javascript .js
        AddType text/x-component .htc
        AddType text/richtext .rtf .rtx
        AddType image/svg+xml .svg .svgz
        AddType text/plain .txt
        AddType text/xsd .xsd
        AddType text/xsl .xsl
        AddType text/xml .xml
        AddType video/asf .asf .asx .wax .wmv .wmx
        AddType video/avi .avi
        AddType image/bmp .bmp
        AddType application/java .class
        AddType video/divx .divx
        AddType application/msword .doc .docx
        AddType application/vnd.ms-fontobject .eot
        AddType application/x-msdownload .exe
        AddType image/gif .gif
        AddType application/x-gzip .gz .gzip
        AddType image/x-icon .ico
        AddType image/jpeg .jpg .jpeg .jpe
        AddType application/vnd.ms-access .mdb
        AddType audio/midi .mid .midi
        AddType video/quicktime .mov .qt
        AddType audio/mpeg .mp3 .m4a
        AddType video/mp4 .mp4 .m4v
        AddType video/mpeg .mpeg .mpg .mpe
        AddType application/vnd.ms-project .mpp
        AddType application/x-font-otf .otf
        AddType application/vnd.oasis.opendocument.database .odb
        AddType application/vnd.oasis.opendocument.chart .odc
        AddType application/vnd.oasis.opendocument.formula .odf
        AddType application/vnd.oasis.opendocument.graphics .odg
        AddType application/vnd.oasis.opendocument.presentation .odp
        AddType application/vnd.oasis.opendocument.spreadsheet .ods
        AddType application/vnd.oasis.opendocument.text .odt
        AddType audio/ogg .ogg
        AddType application/pdf .pdf
        AddType image/png .png
        AddType application/vnd.ms-powerpoint .pot .pps .ppt .pptx
        AddType audio/x-realaudio .ra .ram
        AddType application/x-shockwave-flash .swf
        AddType application/x-tar .tar
        AddType image/tiff .tif .tiff
        AddType application/x-font-ttf .ttf .ttc
        AddType audio/wav .wav
        AddType audio/wma .wma
        AddType application/vnd.ms-write .wri
        AddType application/vnd.ms-excel .xla .xls .xlsx .xlt .xlw
        AddType application/zip .zip
    </IfModule>
    <IfModule mod_expires.c>
        ExpiresActive On
        ExpiresByType text/css A31536000
        ExpiresByType application/x-javascript A31536000
        ExpiresByType text/x-component A31536000
        ExpiresByType text/richtext A3600
        ExpiresByType image/svg+xml A3600
        ExpiresByType text/plain A3600
        ExpiresByType text/xsd A3600
        ExpiresByType text/xsl A3600
        ExpiresByType text/xml A3600
        ExpiresByType video/asf A31536000
        ExpiresByType video/avi A31536000
        ExpiresByType image/bmp A31536000
        ExpiresByType application/java A31536000
        ExpiresByType video/divx A31536000
        ExpiresByType application/msword A31536000
        ExpiresByType application/vnd.ms-fontobject A31536000
        ExpiresByType application/x-msdownload A31536000
        ExpiresByType image/gif A31536000
        ExpiresByType application/x-gzip A31536000
        ExpiresByType image/x-icon A31536000
        ExpiresByType image/jpeg A31536000
        ExpiresByType application/vnd.ms-access A31536000
        ExpiresByType audio/midi A31536000
        ExpiresByType video/quicktime A31536000
        ExpiresByType audio/mpeg A31536000
        ExpiresByType video/mp4 A31536000
        ExpiresByType video/mpeg A31536000
        ExpiresByType application/vnd.ms-project A31536000
        ExpiresByType application/x-font-otf A31536000
        ExpiresByType application/vnd.oasis.opendocument.database A31536000
        ExpiresByType application/vnd.oasis.opendocument.chart A31536000
        ExpiresByType application/vnd.oasis.opendocument.formula A31536000
        ExpiresByType application/vnd.oasis.opendocument.graphics A31536000
        ExpiresByType application/vnd.oasis.opendocument.presentation A31536000
        ExpiresByType application/vnd.oasis.opendocument.spreadsheet A31536000
        ExpiresByType application/vnd.oasis.opendocument.text A31536000
        ExpiresByType audio/ogg A31536000
        ExpiresByType application/pdf A31536000
        ExpiresByType image/png A31536000
        ExpiresByType application/vnd.ms-powerpoint A31536000
        ExpiresByType audio/x-realaudio A31536000
        ExpiresByType image/svg+xml A31536000
        ExpiresByType application/x-shockwave-flash A31536000
        ExpiresByType application/x-tar A31536000
        ExpiresByType image/tiff A31536000
        ExpiresByType application/x-font-ttf A31536000
        ExpiresByType audio/wav A31536000
        ExpiresByType audio/wma A31536000
        ExpiresByType application/vnd.ms-write A31536000
        ExpiresByType application/vnd.ms-excel A31536000
        ExpiresByType application/zip A31536000
    </IfModule>
    <IfModule deflate_module>
        <IfModule filter_module>
            AddOutputFilterByType DEFLATE text/plain text/html
            AddOutputFilterByType DEFLATE text/xml application/xml application/xhtml+xml application/xml-dtd
            AddOutputFilterByType DEFLATE application/rdf+xml application/rss+xml application/atom+xml image/svg+xml
            AddOutputFilterByType DEFLATE text/css text/javascript application/javascript application/x-javascript
            AddOutputFilterByType DEFLATE font/otf font/opentype application/font-otf application/x-font-otf
            AddOutputFilterByType DEFLATE font/ttf font/truetype application/font-ttf application/x-font-ttf
        </IfModule>
    </IfModule>
    <FilesMatch "\.(css|js|htc|CSS|JS|HTC)$">
        <IfModule mod_headers.c>
            Header set Pragma "public"
            Header append Cache-Control "public, must-revalidate, proxy-revalidate"
        </IfModule>
        FileETag MTime Size
    </FilesMatch>
    <FilesMatch "\.(html|htm|rtf|rtx|svg|svgz|txt|xsd|xsl|xml|HTML|HTM|RTF|RTX|SVG|SVGZ|TXT|XSD|X??SL|XML)$">
        <IfModule mod_headers.c>
            Header set Pragma "public"
            Header append Cache-Control "public, must-revalidate, proxy-revalidate"
        </IfModule>
        FileETag MTime Size
    </FilesMatch>
    <FilesMatch "\.(asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|eot|exe|gif|gz|gzip|ico|jpg|j??peg|jpe|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|otf|odb|odc|odf|od?g?|odp|ods|odt|ogg|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|tif|tiff|ttf?|t?tc|wav|wma|wri|xla|xls|xlsx|xlt|xlw|zip|ASF|ASX|WAX|WMV|WMX|AVI|BMP|CLASS|DIV?X|D?OC|DOCX|EOT|EXE|GIF|GZ|GZIP|ICO|JPG|JPEG|JPE|MDB|MID|MIDI|MOV|QT|MP3|M4A|MP4?|M4V?|MPEG|MPG|MPE|MPP|OTF|ODB|ODC|ODF|ODG|ODP|ODS|ODT|OGG|PDF|PNG|POT|PPS|PPT|P?PTX|R?A|RAM|SVG|SVGZ|SWF|TAR|TIF|TIFF|TTF|TTC|WAV|WMA|WRI|XLA|XLS|XLSX|XLT|XLW|Z?IP)$">
        <IfModule mod_headers.c>
            Header set Pragma "public"
            Header append Cache-Control "public, must-revalidate, proxy-revalidate"
        </IfModule>
        FileETag MTime Size
    </FilesMatch>
    
    
    #    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 /community
    
        #    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>
    Thanks again for your help!
     
  6. Mike

    Mike XenForo Developer Staff Member

    I don't see the rules you mentioned in the /community .htaccess. Can you add them again (at the top)?
     
  7. Harness Media

    Harness Media Member

    Oh, so you are saying that the rules I have in the root .htaccess should also be in the /community .htaccess? I've added them there but now anyone going to beerleg.com/community gets redirected to rplstoday.com (root).
     
  8. Mike

    Mike XenForo Developer Staff Member

    In that case, change the rewrite rule to:
    Code:
    RewriteRule (.*)$ http://rplstoday.com/community/$1 [R=301,L]
     
  9. Harness Media

    Harness Media Member

    Now when I go to beerleg.com/community I get this:
    2016-06-18.png
    Sorry for all the hassle, but I do very much appreciate your time.
     
  10. Mike

    Mike XenForo Developer Staff Member

    Just to confirm, I was only referring to replacing one line with that last message (the RewriteRule link). You still need the RewriteCond lines.

    Can you show me what you have put in the community .htaccess?
     
  11. Harness Media

    Harness Media Member

    Got it! Thanks for all your help, it's working great now. Do you have a tip jar somewhere?

    So, for future reference and anyone else looking for this solution, here's what I put above all other rules in each of the .htaccess files:

    root .htaccess
    Code:
    RewriteCond %{HTTP_HOST} ^beerleg.com$ [OR]
    RewriteCond %{HTTP_HOST} ^www.beerleg.com$
    RewriteRule (.*)$ http://rplstoday.com/$1 [R=301,L]
    /community .htaccess
    Code:
    RewriteCond %{HTTP_HOST} ^beerleg.com$ [OR]
    RewriteCond %{HTTP_HOST} ^www.beerleg.com$
    RewriteRule (.*)$ http://rplstoday.com/community/$1 [R=301,L]
     
    Mike likes this.

Share This Page