301 redirect issue with .htaccess

Discussion in 'Apache' started by eleetgeek, Mar 16, 2011.

  1. #1
    Hello,


    
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^example.com [NC]
    RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
    RewriteCond $1 !^(/index\.php|/img|/robots\.txt)
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]
    
    Code (markup):

    Now, I am doing a 301 redirect to www and further I need all request_uri to be directed to index.php then, from index.php I begin with :

    
    $site = 'http://'.$_SERVER['HTTP_HOST'].'/';
    $url = $_SERVER["REQUEST_URI"];
    
    PHP:

    Everything is working FINE!

    But, when I put this site for sitemap generation, it is creating infinite URLs, I am sure, this website does not have more than 100 pages but, it is bursting 500 pages limit and its not just 1 but, I tried with many other. Also when I fetch website as Google-bot, it is coming up with joined links of example and www.example

    Any ideas?


    EDIT:

    I just did a Options+ SymLinks and xml sitemap generators are able to generate site maps for http://www.example.com/ but, it shows error (Error occured and Some error) for http://example.com
    As long as I believe sitemaps should show same results for www version and plain version.
     
    Last edited: Mar 16, 2011
    eleetgeek, Mar 16, 2011 IP