[pmwiki-users] Losing the www. in site URL

marc gmane at auxbuss.com
Sun Dec 3 07:33:31 CST 2006


marc said...
> I have a site where I'm losing the initial www. on the URLs displayed in 
> the browser's URL input field. So, www.example.com/pmwiki/Main displays 
> as example.com/pmwiki/Main.
> 
> Thus I click a link to
>   http://www.example.com/pmwiki
> and get
>   http://example.com/pmwiki/
> 
> This truncation is the same across the PmWiki part of the site.
> 
> I tend to use:
> 
>   $ScriptUrl = 'http://'. $_SERVER['HTTP_HOST'] .'/pmwiki';
>   $PubDirUrl = 'http://'. $_SERVER['HTTP_HOST'] .'/pmwiki/pub';
> 
> in my local/config.php, so that I can use the same config/php locally 
> for testing as on the live site. Checking the site I can see that:
>   $_SERVER['HTTP_HOST']:www.example.com
> 
> Nevertheless, I changed the above to:
> 
>   $ScriptUrl = 'http://www.example.com/pmwiki';
>   $PubDirUrl = 'http://www.example.com/pmwiki/pub';
> 
> What happened is that:
> 
> a link to
>   http://www.example.com/pmwiki
> displays
>   http://example.com/pmwiki/
> 
> but the links are of the expected form:
> 
>   http://www.example.com/pmwiki/Main/WikiSandbox
> 
> Does anyone know why the www. should be 'lost' initially?
> 
> And why changing from $_SERVER['HTTP_HOST'] causes a change of 
> behaviour?
> 
> Thanks.

Some more diagnostic info.

The URL

  http://www.example.com/pmwiki  -> http://example.com/pmwiki/
  http://www.example.com/pmwiki/ -> http://www.example.com/pmwiki/

The former produces 
  $_SERVER['HTTP_HOST'] = example.com
the latter
  $_SERVER['HTTP_HOST'] = www.example.com

I can't recreate this locally, only on a hosted site.

Try these:

  http://auxbuss.com/phpinfo.php
  http://www.auxbuss.com/phpinfo.php

The root .htaccess is:

  RewriteEngine on
  RewriteCond %{HTTP_HOST} ^auxbuss.com$ [NC]
  RewriteRule ^(.*)$ http://www.auxbuss.com/$1 [R=301]


  http://auxbuss.com/pmwiki/phpinfo.php
  http://www.auxbuss.com/pmwiki/phpinfo.php

/pmwiki .htaccess is:

  RewriteEngine on
  RewriteBase /pmwiki
  # Send requests without parameters to pmwiki.php.
  RewriteRule ^$           index.php  [L]
  # Send requests for index.php to pmwiki.php.
  RewriteRule ^index\.php$ pmwiki.php  [L]
  # Send requests to pmwiki.php, appending the query string part.
  RewriteRule ^([^/a-z].*) index.php?n=$1  [QSA,L]


-- 
Best,
Marc





More information about the pmwiki-users mailing list