php - htaccess global rewriting for subdirectories -


let's have following structure:

/api1     /v1 /api2     /v1     /v2 

would possible have .htaccess file in root (/) rewrites requests /api1/v1/* /api1/v1/index.php (same every api/version combination) handle them?

it should behave in such way that:

  • /api1/v1/users -> /api1/v1/index.php,
  • /api1/v1/users/action/paramater -> /api1/v1/index.php
  • /api2/v1/projects/popular -> /api2/v1/index.php
  • /api2/v2/projects/most_popular -> /api2/v2/index.php

you can use code in document_root/.htaccess file:

rewriteengine on rewritebase /  rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^(api[0-9]+/v[0-9]+)/(?!index\.php).*$ $1/index.php [l,nc] 

Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -