Friday, 15 January 2010

.htaccess - htaccess issue with directory when removing extension -



.htaccess - htaccess issue with directory when removing extension -

i utilize htaccess remove .php extension url. problem comes when there's file , directory same name. removing .php extension server thinks i'm trying access directory denies access.

example www.europe.com/italy.php turns www.europe.com/italy have folder named italy, servers denies access saying "forbidden, don't have permission access /italy/ on server"

here's htaccess

options +followsymlinks -multiviews # turn mod_rewrite on rewriteengine on ## hide .php extension # externally redirect /dir/foo.php /dir/foo rewritecond %{the_request} ^[a-z]{3,}\s([^.]+)\.php [nc] rewriterule ^ %1 [r,l,nc] ## internally redirect /dir/foo /dir/foo.php rewritecond %{request_filename}.php -f rewriterule ^ %{request_uri}.php [l]

update: final code working charm!

directoryslash off indexoptions fancyindexing options rewriteengine on rewritecond %{the_request} ^[a-z]{3,9}\ /([^/]+/)*[^.]+\.php rewriterule ^(([^/]+/)*[^.]+)\.php$ http://www.yoursite.com/$1 [r=301,l] rewritecond %{request_filename}.php -f rewriterule ^(([^/]+/)*[^/.]+)$ /$1.php [l]

.htaccess redirect file-extension

No comments:

Post a Comment