I've setup an "admin only" site which uses Path Redirect to redirect <front> to another site (target irrelevant). Anyone who accidentally goes to the domain gets redirected away - perfect...

Then the other day I noticed that cron.php hadn't run for 10 weeks!

I ran wget manually in a terminal...

wget -O /dev/null http://example.com/cron.php

...and noticed it was 301'ing to the Path Redirect target URL. I then changed <front> to test and my cron wget worked fine.

Any idea's why this is happening? I assume cron.php is "bootstrapping" and Drupal see's $_GET['q'] and empty and therefor as a frontpage?

Should Path Redirect be checking the script that invokes hook_init? I believe my Global Redirect project had a similar issue (eg it broke the Ad Module based on a similar bug to this)..

Comments

nicholasthompson’s picture

After putting the <front> redirect back in place, I tried the following wget:

wget -O /dev/null http://example.com/cron.php?q=test

And it worked fine - this is a "workaround" I guess...

dave reid’s picture

Yeah you shouldn't ever be redirecting just with <front>. It's not something I can support. You should likely enable some kind of .htaccess redirection instead.

nicholasthompson’s picture

Ok - fair suggestion... May I add:
1) If that's the case, maybe some validation should be added to avoid ?
2) We wanted to use Path Redirect as it would allow non-techies to change the target URL (for example if they needed a new marketing tracking code in the URL).

dave reid’s picture

Title: Frontpage redirect seems to break cron.php » Do not allow redirects using <front> as the source
Version: 6.x-1.0-beta6 » 6.x-1.x-dev

We should really add the validation (unless it's + query parameters)

tmsimont’s picture

hey to any one else that finds this..

I had the same issue, trying to redirect users to the front page without the real path in the url if they ended up on the real path page..

you can accomplish this like so:


	if(drupal_is_front_page()){
		if(request_uri()==base_path().$_GET['q']){
			drupal_goto("<front>");
		}
	}

john franklin’s picture

Using <front> as the From path also seems to break drush's cron command. That's some serious borkage going on. Enough so the help text in the Add Redirect page should call out <front> and the form verify should reject attempts to redirect <front>.

Here's what worked for me. I added a line to .htaccess in the Rewrite rules section:

RewriteRule ^/*$ /redirected/home/path [L,R=307]

This works for any hostname, any port, and even if they stick extra slashes in the address bar (e.g., http://example.org// ).

(edit: added RewriteRule flags)

joedougherty’s picture

Status: Needs work » Needs review
StatusFileSize
new1.48 KB

As per comment #4, here is a patch against version 6.x-1.x-dev.

1.) It updates the helper text below Front: to: "Enter an internal Drupal path or path alias to redirect (e.g. node/123 or taxonomy/term/123). Fragment anchors (e.g. #anchor) and <front> are not allowed."

2.) It fires form_error in the case that the input for From: is <front>. The user receives the following message: "The source path cannot be set to <front>" in an attempt to maintain consistency with the other error messages in the module.

This has been tested locally on a clean install of Drupal 6.26.

Status: Active » Needs work

The last submitted patch, path_redirect-include-frontpage-validation-836715-3267840.patch, failed testing.

joedougherty’s picture

Status: Needs review » Needs work
StatusFileSize
new1.62 KB

Sorry - trying new patch.

joedougherty’s picture

Status: Needs work » Needs review
StatusFileSize
new1.62 KB