.htaccess - remove index.php from url only for the client -
i know there questions out there solutions not helpful me. i´m using htaccess redirect index.php if request file isn´t defined (code above). i´d add code-line if user requests example: http://www.example.com/test/index.php redirect http://www.example.com/test/ internal redirect index.php. there way extend code works want to?
# add slash rewritecond %{request_uri} !(/$|\.) rewriterule (.*) %{request_uri}/ [r=301,l] # redirect index.php if following sites not match rewritebase / rewritecond %{request_uri} \.(php|sql|tgz|gz|txt|ttf|ttf|log|txt|ini|html|xml|xhtml|htm)$ rewritecond %{request_uri} !^/index.php$ rewritecond %{request_uri} !^/phpinfo.php$ rewritecond %{request_uri} !^/out.php$ rewritecond %{request_uri} !^/sitemap[^0-9]*\.xml$ rewritecond %{request_uri} !^/robots.txt$ rewriterule ^(.*)$ /index.php?dir=$1 [qsa,l] rewritecond %{request_filename} !-f rewritecond %{request_uri} !^/$ rewriterule ^(.*)$ /index.php?dir=$1 [qsa,l]
complete code:
directoryindex index.php index.html options +followsymlinks -multiviews # turn mod_rewrite on rewriteengine on rewritebase / # take off index.php rewritecond %{request_uri} ^(.*/)index\.php$ [nc] rewriterule ^ http://%{http_host}%1 [r=301,l] rewritecond %{request_filename} !-d rewritecond %{request_uri} \.(php|sql|tgz|gz|txt|ttf|ttf|log|txt|ini|html|xml|xhtml|htm)$ rewritecond %{request_uri} !^/((index|phpinfo|out)\.php|robots\.txt|sitemap[^0-9]*\.xml)$ rewriterule ^(.*)$ /index.php?dir=$1 [qsa,l] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^(.+)$ /index.php?dir=$1 [qsa,l] # add slash non-files rewritecond %{request_filename} !-f rewriterule [^/]$ %{request_uri}/ [r=301,l]
Comments
Post a Comment