Link to home
Start Free TrialLog in
Avatar of wal_toor
wal_toorFlag for Netherlands

asked on

htaccess redirect

Hello all,

Is it possible to create a redirect rule when an url does not contain anything after the domain extension? Because I have a local, production and live version the domain extension should be treated as variable.

mydomain.nl -- redirect to --> mydomain.nl/nl
mydomain.nl/ -- redirect to --> mydomain.nl/nl
mydomain.local -- redirect to --> mydomain.local/nl
mydomail.nl/fr -- no redirect
mydomail.local/fr/whatever/comes/next -- no redirect

Can this be done?

Thankz!

Greetz,
walter
Avatar of Derek Jensen
Derek Jensen
Flag of United States of America image

You should be able to accomplish this using a regexp similar to the following:
/mydomai.\.local/

Open in new window

This will match both domains you have listed above; however, I'm sure you'll have to modify it to your needs.
I'm not sure what the exact syntax of the rule should look like, but I do know that .htaccess supports regexes.
ASKER CERTIFIED SOLUTION
Avatar of arober11
arober11
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of wal_toor

ASKER

Spot on!