Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rewrite CSS file for different domains

Status
Not open for further replies.

Geronantimo

Technical User
Apr 3, 2006
79
SE
Hi,

We have a website that can be accessed using two different domains names.

Using the .htaccess file, is it possible to deliver a different CSS file depending on which domain name is used to access the website?

 
Hi

Suppose you have two files, style.css and style-other.css. Link the first into the HTML :
Code:
[b]<link[/b] [maroon]rel[/maroon][teal]=[/teal][green][i]"stylesheet"[/i][/green] [maroon]type[/maroon][teal]=[/teal][green][i]"text/css"[/i][/green] [maroon]href[/maroon][teal]=[/teal][green][i]"style.css"[/i][/green][b]>[/b]
And rewrite the request when comes from the other domain :
Code:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^otherdomain$
RewriteCond %{REQUEST_URI} (.*)style.css
RewriteRule .* %1style-other.css
Note that I would use this only if the site contains static HTML files. For dynamically generated HTML I would solve it programmatically.

Also note that multiple domains pointing to the same content is not really good for SEO.


Feherke.
 
Thanks for the help Feherke,

The two domains in question do have completely different content, but the styles-sheets give each site a different look and feel so the managing the stylesheets was the quickest way to make a visual difference.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top