How does this mod_rewrite code resolve properly?
        Posted  
        
            by 
                user532493
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by user532493
        
        
        
        Published on 2012-06-27T15:10:08Z
        Indexed on 
            2012/06/27
            15:15 UTC
        
        
        Read the original article
        Hit count: 235
        
My .htaccess file is as follows:
Options -Multiviews
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ $1.php
It works, but I'm wondering how it works. For example, if I type in example.com/main, I get the file at www.example.com/main.php. How do I get the .php extension if the code tells the rewriting to stop after adding the www. to the beginning of example.com?
© Stack Overflow or respective owner