Hi Dave!
I'm getting a WSOD when I try to add:

function custom_url_rewrite_outbound(&$path, &$options, $original_path) {

// Used by the Subdomain module to generate URLs with subdomains
if (module_exists('subdomain')) {
subdomain_url_rewrite_outbound($path, $options);
}
}

and

function custom_url_rewrite_inbound(&$result, $path, $path_language) {

// Used by the Subdomain module to correctly interpret URLs with subdomains
if (module_exists('subdomain')) {
subdomain_url_rewrite_inbound($result, $path, $path_language);
}
}

when I try to add this code (from the URL aliases module README.txt. The code isn't, apparently taking, since I can go back and the boxes are empty.

However, my status report (/admin/reports/status) shows:

Url alter Overriding custom_url_rewrite_outbound()
Url alter Overriding custom_url_rewrite_inbound()

I have no other modules, i.e., Domain that should be altering this. This occurs even with the default settings.php

Thanks!
-Brian

Comments

dave reid’s picture

Don't include the function definition. In your case this is only what you should enter in the textareas:

// Used by the Subdomain module to generate URLs with subdomains
if (module_exists('subdomain')) {
  subdomain_url_rewrite_outbound($path, $options);
}
// Used by the Subdomain module to correctly interpret URLs with subdomains
if (module_exists('subdomain')) {
  subdomain_url_rewrite_inbound($result, $path, $path_language);
}
brianbrown’s picture

Thanks, Dave!
But when I enter the above, I get:

Parse error: syntax error, unexpected $end in * * * /sites/all/modules/url_alter/url_alter.module(69) : eval()'d code on line 1

Warning: Cannot modify header information - headers already sent by (output started at * * * /sites/all/modules/url_alter/url_alter.module(69) : eval()'d code:1) in * * * /includes/bootstrap.inc on line 630

Warning: Cannot modify header information - headers already sent by (output started at * * * /sites/all/modules/url_alter/url_alter.module(69) : eval()'d code:1) in * * * /includes/bootstrap.inc on line 631

Warning: Cannot modify header information - headers already sent by (output started at * * * /sites/all/modules/url_alter/url_alter.module(69) : eval()'d code:1) in * * * /includes/bootstrap.inc on line 632

Warning: Cannot modify header information - headers already sent by (output started at * * * /sites/all/modules/url_alter/url_alter.module(69) : eval()'d code:1) in * * * /includes/bootstrap.inc on line 633

Parse error: syntax error, unexpected $end in * * * /sites/all/modules/url_alter/url_alter.module(90) : eval()'d code on line 1

Any suggestions?
Thanks for your prompt assistance!
-Brian

dave reid’s picture

That sounds like something is going wrong in the subdomain functions.

dave reid’s picture

Status: Active » Postponed (maintainer needs more info)

Also, you can go help review the change to help integrate the subdomain module with Url alter at #530326: Prevent custom_url_rewrite_outbound collision and integrate with url_alter.module. Or you might want to try that patch, since then you will not need to enter any code in the settings form. It should work automatically.

brianbrown’s picture

Hi Dave!
None of this worked. The patch was uneventful, since I do bit have the in- and outbound functions patched anywhere else. This was all tried on yet another fresh ("clean and sober") Drupal installation.
Regards,
Brian Brown, Ph.D.

dave reid’s picture

brianbrown: Sorry to hear you are quitting Drupal and for the many problems you've experienced along the way. I could have really used your help in find where the problem is here since I don't use the subdomain module. I guess I'll keep working on it.

dave reid’s picture

You weren't by chance also using the Global redirect module? There seems to be an issue with that module when used in conjunction with subdomain/url_alter. See #346911: Redirect Loop and custom_url_rewrite ignored.

brianbrown’s picture

Hi Dave!
I'm terribly sorry for the rant/flame/whatever. I was having a bad day and my frustrations just seemed to culminate!
I will help you whenever/wherever I can!
I can tell you that I DID have everything working yesterday, that is to say, no WSOD or php errors and the tests at the subdomain module all succeeded. Now this morning, without making any changes, I have errors again (see what I mean about frustration?).
This is what I did to get it working (at least for a few hours; and no, Global Redirect not installed, but Sub-path URL Aliases is):

1. NO rewrite patch for inbound/outbound redirects in settings.php.
2. Uncomment out the base_url variable, i.e.,
$base_url = 'http://www.example.com'; // NO trailing slash!
3. Uncomment out the cookie_domain variable, i.e.,
cookie_domain = 'www.example.com';
Note that if you are using the 'www' prefix, it MUST be included in #2 and 3, above, even though the variable is named 'base url' and may be misleading (I would suggest that a clarification be made to the core settings.php commentary to make this clearer). You must make these agree with any .htaccess redirects, in any case, I believe!
4. Patch to subdomain module (2 files) applied and manually confirmed (#530326: Prevent custom_url_rewrite_outbound collision and integrate with url_alter.module)
5. Observe that "status report" (admin/reports/status/) shows that "Url alter [is] Overriding custom_url_rewrite_outbound()" and that "Url alter" [is] Overriding custom_url_rewrite_inbound()"
without, repeat WITHOUT adding anything to the textboxes in the Url Alter module. Textboxes are left EMPTY!
-----
It seemed to me that this all began to work correctly when I save the configuration on one (i do not remember which)
Now, as of this moment at least, I have:

DNS server - show/hide details Working
test-1.example.com successfully resolved to *.*.*.*
test-2.example.com successfully resolved to *.*.*.*
test-3.example.com successfully resolved to *.*.*.*
Web server - show/hide details Not working yet

HTTP request to http://subdomain-test.example.com/subdomain/test returned the following result:
HTTP_HOST:
QUERY_STRING:
REQUEST_URI:
SCRIPT_FILENAME:
drupal_get_normal_path:

Your web server is not routing subdomains to your Drupal directory.
Possible Solutions:

* If you're running Apache, confirm you have the wildcard directive, ServerAlias *.example.com, in the VirtualHost declaration in your Apache configuration
* Confirm there are no rogue URL rewrite rules in your Apache configuration or .htaccess file

Drupal's inbound URL rewriting - show/hide details Not working yet
HTTP request to http://subdomain-test.example.com/subdomain/test resulted in an internal Drupal path of . It should have been ~subdomain-test/subdomain/test

The custom_url_rewrite_inbound() function in settings.php is rewriting the internal path incorrectly. Did you patch settings.php? See readme.txt for instructions.
Drupal's outbound URL rewriting - show/hide details Working
Drupal API: url('~subdomain-test/subdomain/test') returned 'http://subdomain-test.example.com/subdomain/test'
$cookie_domain in settings.php - show/hide details Set

And from the status report (admin/reports/status/):

Url alter Overriding custom_url_rewrite_inbound()
Url alter Overriding custom_url_rewrite_outbound()
Web server Apache/2.2.11 (Unix) mod_ssl/2.2.11 OpenSSL/0.9.8k DAV/2 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635

I am also getting this warning, which I never received before:
warning: file_get_contents(http://subdomain-test.example.com/subdomain/test) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 503 Service unavailable in / * path to modules * /sites/all/modules/subdomain/subdomain_debug.inc on line 57.

I hope that you can decipher my cut-and-pasting. I have altered personally-identifying data.
Thanks so much!
Regards,
-Brian

brianbrown’s picture

P.S.
I have the tilde '~' set to "do nothing" in the alias module and am using an .htaccess with no redirection/rewrite rules (even tried the default Drupal .htaccess).
-B

brianbrown’s picture

I FINALLY got this to work! WHEW!
-B

dave reid’s picture

Status: Postponed (maintainer needs more info) » Fixed

@brianbrown: YAY! Anything you did special?

brianbrown’s picture

I dunno!!! I set it aside for a while and tried it on a fresh install! Next task is to get subdomains to work!
Yikes!
Thanks!
-B

brianbrown’s picture

Well, it worked for just over a week!
Parse error: syntax error, unexpected $end in /* * * /sites/all/modules/url_alter/url_alter.module(69) : eval()'d code on line 1
-B

brianbrown’s picture

Hmmm...
Mysteriously working again!
-B

dave reid’s picture

I am not sure what to tell you besides you might have a ghost in your computer. :)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.