Re: [users@httpd] Rewriting depending on access through subdomain

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 10/12/06, Hermann Kleister <h_kleister@xxxxxxxx> wrote:
Hello,
I have a shared hosting setup with one domain example.org and a
subdomain test.example.org. The document root of example.org is
/home/user1/example.org/ and the document root for
test.example.org lies within this, in
/home/user/example.org/test/. A document in
/home/user/example.org/test/, e.g. foo.html can thus be reached
as http://example.org/test/foo.html and
http://test.example.org/foo.html. Now I want to rewrite documents
under test/ using mod_rewrite but this leads to problems depending
how e.g. foo.html is accessed.

For the first case

RewriteBase /test/
Rewrite ^(.*)\.html$ $1-new.html [R=301, L]

leads to success, for the second it needs to be

RewriteBase /
Rewrite ^(.*)\.html$ $1-new.html [R=301, L]

How can I solve this for both cases?
Note I dont have access to httpd.conf.

Forget RewriteBase for this application and construct a whole absolute
URL conditional on the accessed hostname.  For example:
RewriteCond %{HTTP_HOST} ^test [NC]
Rewrite .*/([^/]*)\.html http://test.example.org/test/$1-new.html [R=301,L]
Rewrite .*/([^/]*)\.html http://example.org/test/$1-new.html [R=301,L]

Even better, just redirect all requests to the canonical hostname for
the content.  It is a bad idea to have the same content accessible
under multiple URLs.

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
  "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx



[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux