Link to home
Create AccountLog in
Avatar of bretterer
brettererFlag for United States of America

asked on

.htaccess redirect

Hello All,

I would like to know the htaccess needed to redirect this url:
http://www.mydomain.com/foo/(WILDCARDFOLDER)/index.php
to go to
http://www.mydomain.com/foo/index.php

the index.php is important because i have files inside the wildcardfolder that do need to display.
for example:
http://www.mydomain.com/foo/bar/foobar.php
Avatar of Salih Maoui
Salih Maoui
Flag of Algeria image

You can use one of these in your .htaccess file:

redirect 301 /(WILDCARDFOLDER)/index.php http://www.mydomain.com/foo/index.php 
redirect permanent /(WILDCARDFOLDER)/index.php  http://www.mydomain.com/foo/index.php
redirectpermanent /(WILDCARDFOLDER)  http://www.mydomain.com/foo/index.php
Avatar of bretterer

ASKER

right but is there a way to do some sort of regex for the (WILDCARDFOLDER)?
Something to this affect is what im looking for but this does not work

redirect 301 /foo/[a-zA-Z0-9\-]+/index.php /foo
ASKER CERTIFIED SOLUTION
Avatar of Salih Maoui
Salih Maoui
Flag of Algeria image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account