Help with .htaccess rewrite rule please

Ok I have inherited a drupal based website that serves up different content depending on the url used to access the site.

There is a mobile version accessible at m.domain.ca

and then the standard website at www.domain.ca

I need to create a redirect rule for the following mobile page to standard page only

m.domain.ca/tours > www.domain.ca/tour

Can somebody please help I have been struggling with this for hours with no luck.

JC,

Since you’ve not shown your coding attempt, let me merely say that either mod_alias (Redirect) or mod_rewrite (more powerful but takes a bit more server resources) to:

  1. In the m.domain.ca directory (a subdirectory of domain.ca?), use .htaccess with mod_rewrite to check on the {REQUEST_URI} being EXACTLY tour

  2. Redirect to the absolute domain (because you can’t get to the main domain from a subdirectory … or another website [remember, subdomains ARE separate websites]) with the same {REQUEST_URI} string (tour).

Easy peasy!

If you can’t translate that to actual code, have a read of the mod_rewrite tutorial linked in my signature (THEN PM me with your code and I’ll polish it off for you). Alternatively, bring your code back here and have others make suggestions; I’m scarce around here these days so PM is better if you want my comments quickly.

Regards,

DK

Thanks so much DK for your assistance. However I think my situation is a bit unique the website I am working with uses the drupal domain access module.

The Domain Access project is a suite of modules that provide tools for running a group of affiliated sites from one Drupal installation and a single shared database. The module allows you to share users, content, and configurations across a group of sites such as:

example.com
one.example.com

so you see the primary site and the subdomain actually share the same directory. Which is why I am having troubles redirecting from one to the other.

I am basically looking for a rule that I can put on the main htaccess file that says

if accessing m.domain.ca/tours redirect to www.domain.com/tour however by you message it sounds like this might simply not be possible?

JC,

Au contraire! Use a RewriteCond to test for the (sub) domain then redirect to the (main) domain’s link. Still easy peasy (and it will ONLY redirect m.domain.com’s tour request)!

Regards,

DK