1


I'm new to this (wonderful) website!
I did search for an answear to my problem but I could not find it.
(Q: bad english. A: I'm italian, sorry.)

My goal:

I would host in a domain 2 different websites, each of them using their proper htaccess rules.


The structure:

/index.html --> empty page.

/site1/index.html
/site1/styleA.css
/site1/logo.png

/site2/index.html
/site2/styleB.css
/site2/logo.png


The problem:

/site1/index.html gets the stylesheet file using absolute path:

<link rel="stylesheet" type="text/css" href="/style.css" />

this way it try to get the "style.css" file in the root directory (404).

Same problem with site2 and every other file that use absolute path.


More info:

  • Sites are stored in folders only to test them, they will be moved to different domains once ready so I would not edit every absolute path.
  • I'm not using Wordpress, Drupal or similar. They're all my creations.



The Question:

Is it possible to solve the 'absolute path' problems using only .htaccess file(s)?
If not, what would you suggest me to do?

4

1 回答 1

0

我想你可以检查推荐人:

RewriteEngine On
RewriteCond %{HTTP_REFERER} /site1/
RewriteCond %{REQUEST_URI} !^/site1/
RewriteRule ^(.*)$ /site1/$1 [L]

RewriteCond %{HTTP_REFERER} /site2/
RewriteCond %{REQUEST_URI} !^/site2/
RewriteRule ^(.*)$ /site2/$1 [L]

这不会重定向浏览器,因此浏览器可能会缓存“/style.css”并且两个站点混合在一起,因此您可能希望通过将标志从 更改为 来重定向浏览[L][L,R]

于 2013-08-20T19:19:08.860 回答