apache - htaccess /index.php extensions shows after redirected from old domain -


i have redirect issue occurring, far, i've redirected non-www www, , old domain new domain. i've remove /index.php extension works unless redirecting old domain. ideally i'd not occur. shot in dark me, don't understand of means (htaccess code), got working part far.

what trying do: i'm attempting remove .php extensions (some of pages on old domain use .html extension, .php pages. there's redirect in there) , have routed new www.domain.com (not domain.com).

is there specific order execute redirects in? or missing entirely. .htaccess isn't strong suite. additionally, should have these in separate <ifmodules>? (they are, combined them 1 less code in post)

<ifmodule mod_rewrite.c>      directoryindex index.php     adddefaultcharset utf-8     options +followsymlinks -multiviews -indexes      rewriteengine on     rewritebase /      # redirect new domain     rewritecond %{http_host} !newdomain.com$ [nc]     rewriterule ^(.*)$ http://www.newdomain.com/$1 [l,r=301]      # html > php     rewriterule ^(.*)\.html$ $1.php [l,r]      #not sure does, here, i'm leaving it... site not use ssl.     rewritecond %{https} =on     rewriterule ^ - [env=proto:https]     rewritecond %{https} !=on     rewriterule ^ - [env=proto:http]       # force www     rewritecond %{https} !=on     rewritecond %{http_host} !^www\. [nc]     rewritecond %{server_addr} !=127.0.0.1     rewritecond %{server_addr} !=::1     rewriterule ^ %{env:proto}://www.%{http_host}%{request_uri} [r=301,l]       # remove /index.php     rewriterule ^index.php/(.*)$ /$1 [r=302,l]     rewritecond %{request_filename} !-f     rewritecond %{request_filename} !-d     rewritecond $1 !^(index\.php|images|robots\.txt)     rewriterule ^(.*)$ index.php?/$1 [l]   </ifmodule> 

please give following try. i've shuffled things around , simplified them you. descriptions in comments.

directoryindex index.php adddefaultcharset utf-8  <ifmodule mod_rewrite.c>      options +followsymlinks -multiviews -indexes      # fire engines     rewriteengine on      # base not needed. enable if think might needed.     #     # rewritebase /      # redirect new domain (self-explanatory)     rewritecond %{http_host} !newdomain.com$ [nc]     rewriterule ^(.*)$ http://www.newdomain.com/$1 [r=301,l]      # force www. on newdomain.com (plain method)     # if want prevent when using localhost/127.0.0.1/::1,     # uncomment next 2 lines above rule.     rewritecond %{http_host} ^newdomain.com [nc]     # rewritecond %{server_addr} !=localhost     # rewritecond %{server_addr} !=127.0.0.1     # rewritecond %{server_addr} !=::1     rewriterule ^(.*)$ http://www.newdomain.com/$1 [r=301,l]      # remove "index.php"     rewriterule ^index.php(/.*)?$ $1 [r=302,l]      # redirect *.html *.php     rewriterule ^(.*).html$ $1.php [r=302,l]      # if request not match file/directory,     # internally map query_string index.php.     # we're using query string, might best allow     # new query strings well.     #     # if rather use request_uri, use commented     # rule @ bottom , make sure comment out first one.     rewritecond %{request_filename} !-f     rewritecond %{request_filename} !-d     rewriterule ^(.*)$ index.php?/$1 [qsa,l]     # rewriterule ^(.*)$ index.php/$1 [qsa,l]  </ifmodule> 

regarding 302 redirects - make them 301s if you're happy , wish them permanent.


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -