Tuesday 15 January 2013

apache - htaccess consolidate root to url and hide index.php -



apache - htaccess consolidate root to url and hide index.php -

i have these 2 htaccess rewrites (which culled elsewhere) function independently x or y site. can't figure out how write both functions work properly.

redirect requests missing "www":

rewritecond %{http_host} !^www.example.com$ [nc] rewriterule ^(.*)$ http://www.example.com/$1 [l,r=301]

redirect requests containing "index.php":

rewritecond %{the_request} ^[a-z]{3,9}\ /(.*)index\.php($|\ |\?) rewriterule ^ /%1 [r=301,l]

additionally, former function works rewrite example.com www.example.com. however, have site in subdirectory on root own "independent" url. function rewrites url www.anotherexample.com www.example.com/anotherexample.

how consolidate these single workable function without rewriting subdirectory site url? in advance.

you can maintain these combined rules in root .htaccess:

rewriteengine on rewritecond %{http_host} ^example\.com$ [nc] rewriterule ^ http://www.%{http_host}%{request_uri} [ne,l,r=301] rewritecond %{the_request} /index\.php [nc] rewriterule ^(.*?)index\.php$ /$1 [l,r=301,nc,ne]

php apache .htaccess mod-rewrite redirect

No comments:

Post a Comment