I have a subdomain pointing at my site; I'd like people who enter the site via that subdomain to go to a different front page from those entering via the regular domain. I'm using Drupal v6.15 and module version 6.x-1.2; I tried adapting the steps in #142796: Front Page Designation based on theme but without success so far - with the settings and code below it always redirects to /node, no matter the domain. Any help gratefully received - my PHP knowledge is very minimal, so the problem's probably very obvious.
Module permissions: enabled for me
Settings:
- select type: Redirect
- Redirect to: node
- Allow embedded PHP code...: yes
<?php
$newfront = 'scottishhandbooks'; // specify where subdomain users are redirected
$regularfront = 'front'; // specify where other users are redirected
$checkdomain = <a href="http://newscot.cpag.org.uk;" title="newscot.cpag.org.uk;" rel="nofollow">newscot.cpag.org.uk;</a> // the domain name you want to redirect visitors coming from
$comingfrom = $_SERVER["HTTP_REFERRER"]; // checks to see where the visitor is coming from
if (stristr($comingfrom, $checkdomain))
{
// redirect users coming from $checkdomain to $newfront
drupal_goto($path = $newfront, $query = NULL, $fragment = NULL);
}
else {
// redirect regular users to $regularfront
drupal_goto($path = $regularfront, $query = NULL, $fragment = NULL);
}
?>
Comments
Comment #1
Dublin Drupaller commentedyou're redirecting to node. that will just redirect everyone to
/nodeI would tend to put the snippet in the front_page settings and select THEMED instead of redirect.
as an example see below where the node ID for the regular front page is 13.
hope that helps
dub
Comment #2
adam_b commentedNot working for me, I'm afraid. I entered:
Settings:
- select type: themed
- Redirect to: [blank]
- Allow embedded PHP code...: yes
Code:
For the normal domain (http://new.cpag.org.uk) I get
Parse error: syntax error, unexpected '<' in /var/www/vhosts/cpa/includes/common.inc(1685) : eval()'d code on line 4, but if I go directly to http://new.cpag.org.uk/node/275 it works fine.For the subdomain (http://newscot.cpag.org.uk) I get an "Access denied" error, but if I go directly to http://newscot.cpag.org.uk/scottishhandbooks (a view page, so there isn't a node ID) it works fine.
Comment #3
Dublin Drupaller commentedchange line 4 to this:
$checkdomain = 'http://newscot.cpag.org.uk';or this:
$checkdomain = 'newscot.cpag.org.uk';and make sure you have permissions correctly setup for the front_page under users-> access control.
if the redirect to the view page is still giving you grief....change it from a goto to an embed view instead.
hope that helps
dub
Comment #4
adam_b commentedOkay... the "Access denied" problem was a permissions issue, as you suggested.
Now I'm getting the default front page (node/275) for both domains - and the page text isn't being rendered properly. The source code is missing the [h1] and [p] tags, as in:
I've tried both alternatives for line 4; I'm not certain what you meant by "embed" but I tried changing
drupal_gototodrupal_embed- didn't appear to make any difference.Any more ideas?
Comment #5
mrgoltra commentedsubscribing
Comment #6
simon georges commentedIs there still an issue with latest versions?
Comment #7
simon georges commentedThe 6.x version of "Front page" is not maintained any more. This issue is closed for this reason.
Please upgrade to a supported version of the module and re-open if you still have the issue.