httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Apisilp Trunganont" <apisil...@hotmail.com>
Subject [users@httpd] How to redirect every document URL except image?
Date Sun, 22 Sep 2002 13:50:24 GMT
Hello,

My web site has 2 URL which contains same content.
(http://www.domain.co.th and http://www.domain.com)
Visitors get http://www.domain.co.th/test.html same as
http://www.domain.com/test.html. But I will terminate
www.domain.co.th and use only www.domain.com.
So I write Rewrite Rule like this.

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.domain\.co\.th$
RewriteRule ^/(.+)$ http://www.domain.com/$1 [R]

This rule works. If visitors request http://www.domain.co.th/test.html,
web server will redirect to http://www.domain.com/test.html.
But I found a problem about images. If test.html contains
this tag:

<img src="http://www.domain.co.th/image.gif">

Web browser will diaplay broken image. Because browser
requests http://www.domain.co.th/image.gif and server
responses redirect command, not image data. Browser
receives redirect command but doesn't try to request
again. So it doesn't understand image format which contains
"Location: ..." and displays broken image.

So I should redirect every document to new URL except
images (*.gif, *.jpg). I writes new Rewrite Rule like this.

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.domain\.co\.th$
RewriteRule ^/(.+)(?<!\.(gif|jpg))$ http://www.domain.com/$1 [R]

It doesn't work. Apache tells me "RewriteRule: cannot compile
regular expression '^/(.+)(?<!\.(gif|jpg))$'". I think this regexp
is too complicate.

Anyone has the advice?

Thanks,
Apisilp.


_________________________________________________________________
Join the world’s largest e-mail service with MSN Hotmail. 
http://www.hotmail.com


---------------------------------------------------------------------
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@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message