apache - Hide subfolder in URL with .htaccess -


i have url structure this: www.mydomain.com/foo/bar/index

and want achieve this: www.mydomain.com/bar/index

i have rewrite rule remove .php url:

rewriteengine on rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewriterule ^(([a-za-z0-9\-]+/)*[a-za-z0-9\-]+)?$ $1.php 

so, how can add new rule hide foo subfolder in compliance rule implemented?

you can have htaccess one:

rewriteengine on  # add /foo/ if not there rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewriterule !^foo/ foo%{request_uri} [l,nc]  # add .php rewritecond %{request_filename} !-d rewritecond %{request_filename}.php -f rewriterule ^(.+?)/?$ $1.php [l] 

Comments

Popular posts from this blog

javascript - Confirm a form & display message if form is valid with JQuery -

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -