.htaccess - Redirect URL using htaccess if it contains a directory and ends in php -


i want redirect url's such

 example.com/blog/product.php 

to

 example.com/product.php 

i.e. if url contains /blog , ends in .php want redirect url /blog removed.

how go doing this?

thanks

inside /blog/.htaccess can have code:

rewriteengine on  rewriterule ^([^./]+)\.php$ /$1 [l,nc,r=301] 

if /blog/.htaccess doesn't exist in root .htaccess can have rule:

rewriterule ^blog/([^./]+)\.php$ /$1 [l,nc,r=301] 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -