Mod_rewrite and preview image path based on domain

Discuss practical ways rearrange URLs using mod_rewrite.

Mod_rewrite and preview image path based on domain

Postby irishguy » Mon Jun 09, 2008 5:52 am

Hi I'm new to this forum and I am hoping someone can help me.

I wish to change the image and css paths on my website depending on whether it is accessed by domain or IP.

So for example if the user access the site at www.domain.com

the image and css path is /assets/img/ and /assets/css/

But if they access it at 192.60.60.60 they get

/assets/img_v2/ and /assets/css_v2/

Is this possible, any ideas?

is it something like:
Code: Select all
RewriteCond %{REMOTE_ADDR} 192.60.60.10
RewriteRule /assets/img/(\*)$ /assets/img_v2/$1 [L]
irishguy
 
Posts: 1
Joined: Mon Jun 09, 2008 5:46 am

Postby richardk » Mon Jun 09, 2008 1:08 pm

You want HTTP_HOST. Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} ^192\.60\.60\.10$
RewriteRule ^assets/(css|img)(/(.*))?$ /assets/$1_v2/$3 [L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 87 guests

cron