.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] 
  1. this rule captures whole uri except last optional slash in back-reference $1.
  2. it constructs full filesystem path using %{document_root}/restapi/$1.html %{document_root} internal mod_rewrite variable representing value of actual document_root path in system.
  3. using -f checks whether .html fils exists.
  4. if condition true routes .html file.

Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -