Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Feb 2012
    Posts
    56
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Unhappy .htaccess redirect issue - robots.txt

    Hello all,

    Hoping someone can help with this issue with my .htaccess redirect. so a bit of history, I had a Vbulletin (3.8) forum script that had the .htaaccess file you see below, I was using VBSEO (an SEO script that change the URL to be search engine friendly.) I then moved my forum over to Xenforo software, so the threads needed to be redirected as well as my URL - here is the additional code I was given which I just dropped in the top of the .htaccess file.

    Code:
    Options -Indexes	
    RewriteEngine On
    RewriteCond %{HTTP_HOST} www.mysite.com$
    RewriteRule ^(.*)$ http://mysite.com/$1 [R=301,L]
    RewriteRule ^[^/]+/.+-([0-9]+)/$ /community/index.php?threads/$1/ [R=301,L]
    RewriteRule ^forum\.php$ /community/ [R=301,L]
    RewriteRule ^(images|dir2|dir3|dir4)/.*$ - [S=1]
    RewriteRule ^.*$ /community/ [R=301,L]

    The problem is this,
    when looking for www.mysite.com/robots.txt it redirects back to www.mysite.com

    Please help with this issue, its frustrating to say the least!

    Thanks in advance!

    Code:
    Options -Indexes	
    RewriteEngine On
    RewriteCond %{HTTP_HOST} www.mysite.com$
    RewriteRule ^(.*)$ http://mysite.com/$1 [R=301,L]
    RewriteRule ^[^/]+/.+-([0-9]+)/$ /community/index.php?threads/$1/ [R=301,L]
    RewriteRule ^forum\.php$ /community/ [R=301,L]
    RewriteRule ^(images|dir2|dir3|dir4)/.*$ - [S=1]
    RewriteRule ^.*$ /community/ [R=301,L]
    
    # Use PHP 5.3
    AddType application/x-httpd-php53 .php 
    
    # Ticket PBB-18872701
    <IfModule mod_suphp.c>
      suPHP_ConfigPath /home/admin/public_html
      <Files php.ini>
        order allow,deny
        deny from all
      </Files>
    </IfModule> 
    # Ticket PBB-18872701
    
    DirectoryIndex index.php
    #RewriteEngine Off
    
    # Comment the following line (add '#' at the beginning)
    # to disable mod_rewrite functions.
    # Please note: you still need to disable the hack in
    # the vBSEO control panel to stop url rewrites.
    RewriteEngine On
    
    RewriteCond %{HTTP_HOST} ^mysite.com$
    RewriteRule ^/?$ "http\:\/\/www\.mysite\.com\/" [R=301,L]
    
    RewriteCond %{HTTP_HOST} ^mysite.com$
    RewriteRule ^forum\.php\/?(.*)$ "http\:\/\/www\.mysite\.com\/forum\.php$1" [R=301,L]
    
    # Some servers require the Rewritebase directive to be
    # enabled (remove '#' at the beginning to activate)
    # Please note: when enabled, you must include the path
    # to your root vB folder (i.e. RewriteBase /forums/)
    #RewriteBase /
    
    #RewriteCond %{HTTP_HOST} !^www\.mysite\.com
    #RewriteRule (.*) http://www.mysite.com/$1 [L,R=301]
    
    RewriteRule ^((urllist|sitemap).*\.(xml|txt)(\.gz)?)$ vbseo_sitemap/vbseo_getsitemap.php?sitemap=$1 [L]
    
    RewriteCond %{REQUEST_URI} !(admincpvioc1/|modcpvioc2/|cron|vbseo_sitemap)
    RewriteRule ^((archive/)?(.*\.php(/.*)?))$ vbseo.php [L,QSA]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !/(admincpvioc1|modcpvioc2|clientscript|cpstyles|images)/
    RewriteRule ^(.+)$ vbseo.php [L,QSA]
    
    <Files 403.shtml>
    order allow,deny
    allow from all
    </Files>
    
    RewriteCond %{HTTP_USER_AGENT} ^Baiduspider.* [NC]
    
    #RewriteCond %{HTTP_HOST} ^mysite.com$
    #RewriteRule ^/?$ "http\:\/\/www\.mysite\.com\/" [R=301,L]
    
    #RewriteCond %{HTTP_HOST} ^mysite.com$
    #RewriteRule ^forum\.+\/?(.*)$ "http\:\/\/www\.mysite\.com\/forum\.php$1" [R=301,L]
    # Expire images header
    ExpiresActive On
    ExpiresDefault A0
    ExpiresByType image/gif A2592000
    ExpiresByType image/png A2592000
    ExpiresByType image/jpg A2592000
    ExpiresByType image/jpeg A2592000
    ExpiresByType image/ico A2592000
    ExpiresByType text/css A2592000
    ExpiresByType text/javascript A2592000
    # compress text, html, javascript, css, xml:
    AddOutputFilterByType DEFLATE text/plain
    AddOutputFilterByType DEFLATE text/html
    AddOutputFilterByType DEFLATE text/xml
    AddOutputFilterByType DEFLATE text/css
    AddOutputFilterByType DEFLATE application/xml
    AddOutputFilterByType DEFLATE application/xhtml+xml
    AddOutputFilterByType DEFLATE application/rss+xml
    AddOutputFilterByType DEFLATE application/javascript
    AddOutputFilterByType DEFLATE application/x-javascript
    # Or, compress certain file types by extension:
    <files *.html>
    SetOutputFilter DEFLATE
    </files>
    
    RewriteEngine On
    RewriteRule ^Microsoft-Server-ActiveSync$ hgpush/index.php

  • #2
    Senior Coder Arbitrator's Avatar
    Join Date
    Mar 2006
    Location
    Splendora, Texas, United States of America
    Posts
    3,371
    Thanks
    32
    Thanked 286 Times in 280 Posts
    Quote Originally Posted by tommydamic68 View Post
    The problem is this,
    when looking for www.mysite.com/robots.txt it redirects back to www.mysite.com

    Please help with this issue, its frustrating to say the least!
    I don't see anything in your code that could be causing this result. The following code looks bad though:

    Code:
    RewriteCond %{HTTP_HOST} www.mysite.com$
    RewriteRule ^(.*)$ http://mysite.com/$1 [R=301,L]
    That's stripping the "www." which seems odd given that you're re-adding it in a later rule:

    Code:
    RewriteCond %{HTTP_HOST} ^mysite.com$
    RewriteRule ^/?$ "http\:\/\/www\.mysite\.com\/" [R=301,L]
    You also have four bad media type references, by the way. application/x-javascript and image/jpg are invalid; you already have the valid ones, so I'm not sure why they're there. image/ico is also invalid and should be image/vnd.microsoft.icon. text/javascript is valid, but deprecated, and should be application/javascript.
    For every complex problem, there is an answer that is clear, simple, and wrong.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •