php - How does this mod_rewrite code resolve properly? -


my .htaccess file 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, i'm wondering how works. example, if type in example.com/main, file @ www.example.com/main.php. how .php extension if code tells rewriting stop after adding www. beginning of example.com?

edit: or should create unique id purpose of logging in remembered user?

the particular behavior you're asking comes because rule

rewriterule ^(.*)$ http://www.example.com/$1 [r=301,l] 

is 301 redirect; instructs browser initiate new http request. l causes (can cause) last rule executed that request; new request comes in correct hostname , proceeds onward.


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -