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

c# - Update a combobox from a presenter (MVP) -

How to understand 2 main() functions after using uftrace to profile the C++ program? -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -