php - .htaccess only apply to it's own directory -
i want domains bit tidier removing extensions in url. here 2 examples.
before: domain.ext/index.php
after: domain.ext/index/
this i've gathered (inactive) question here:
rewritecond %{request_filename} !-d rewritecond %{the_request} ^get\ /[^?\s]+\.php rewriterule (.*)\.php$ /$1/ [l,r=301] rewritecond %{request_filename} !-d rewriterule (.*)/$ $1.php [l] rewritecond %{request_filename}.php -f rewriterule .*[^/]$ $0/ [l,r=301]
right i'm developing in directory root, , it's replacing following url:
domain.ext/versionx/search.php
with:
domain.ext/search.php
which of course doesn't exist right now. there way modify code affect files in it's own directory?
you can use code instead:
rewritecond %{the_request} \s/+(?:index)?(.*?)\.php[\s?] [nc] rewriterule ^ /%1/ [r=301,l,ne] rewritecond %{request_filename} !-d rewritecond %{document_root}/$1.php -f [nc] rewriterule ^(.+?)/?$ /$1.php [l] rewritecond %{request_filename} !-f rewriterule [^/]$ %{request_uri}/ [l,r=301]
if doesn't work reason provide details url doesn't work , location of .htaccess , if there other rules also.
Comments
Post a Comment