.htaccess - Rewriting url rule applied on a folder -
i have url looks : www.mysite.com/directory1/directory2/directory3 .
using htaccess want define rewrite rule able redirect last piece of url in example (directory3) directory3.html
has idea ?
you can use code in document_root/.htaccess file:
rewriteengine on rewritebase /restapi/ rewritecond %{document_root}/restapi/$1\.html -f [nc] rewriterule ^(.+?)/?$ $1.html [l] - this rule captures whole uri except last optional slash in back-reference
$1. - it constructs full filesystem path using
%{document_root}/restapi/$1.html%{document_root}internalmod_rewritevariable representing value of actualdocument_rootpath in system. - using
-fchecks whether.htmlfils exists. - if condition true routes
.htmlfile.
Comments
Post a Comment