Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

htaccess redirect

Posted on 2012-09-06
3
Medium Priority
?
414 Views
Last Modified: 2012-09-07
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
0
Comment
Question by:wal_toor
3 Comments
 
LVL 9

Expert Comment

by:Derek Jensen
ID: 38372554
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.
0
 
LVL 26

Accepted Solution

by:
arober11 earned 2000 total points
ID: 38375863
Yes:

RewriteEngine On

RewriteCond  %{HTTP_HOST} mydomain.nl    [OR]
RewriteCond  %{HTTP_HOST} mydomain.local
RewriteRule  ^/?$    /nl   [L,R=301]

Open in new window

0
 
LVL 8

Author Closing Comment

by:wal_toor
ID: 38375979
Spot on!
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
What You Need to Know when Searching for a Webhost Provider
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…
Suggested Courses
Course of the Month11 days, 18 hours left to enroll

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question