使用.htaccess重定向后无法显示图片,CSS失效,该如何处理

WBOY
Release: 2016-06-13 13:38:15
Original
1457 people have browsed it

使用.htaccess重定向后无法显示图片,CSS失效
我的网站根目录下有三个子目录,分别通过htaccess绑定到了同一域名下的不同主机名,根目录下的.htaccess的具体内容如下: 

 
RewriteEngine On 

RewriteCond %{HTTP_HOST} ^(www\.)?mydomain\.org$ 
RewriteCond %{REQUEST_URI} !^/wp/ 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ /wp/$1 
RewriteCond %{HTTP_HOST} ^(www\.)?mydomain\.org$ 
RewriteRule ^(/)?$ wp/index.php [L] 

RewriteCond %{HTTP_HOST} ^(bbs\.)?mydomain\.org$ 
RewriteCond %{REQUEST_URI} !^/bbs/ 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ /bbs/$1 
RewriteCond %{HTTP_HOST} ^(bbs\.)?mydomain\.org$ 
RewriteRule ^(/)?$ bbs/index.php [L] 

RewriteCond %{HTTP_HOST} ^(blog\.)?mydomain\.org$ 
RewriteCond %{REQUEST_URI} !^/blog/ 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ /blog/$1 
RewriteCond %{HTTP_HOST} ^(blog\.)?mydomain\.org$ 
RewriteRule ^(/)?$ blog/index.php [L] 

 

现在我需要把这个域名泛解析到blog目录(*.mydomain.org),同时保持另外两个目录的解析不变。尝试对最后一段作以下修改后(前面的内容不变),出现问题:另两个目录中的网站内的图片无法显示,CSS全部失效。 
修改如下: 

RewriteCond %{HTTP_HOST} ^(.*\.)?mydomain\.org$ 
RewriteCond %{REQUEST_URI} !^/blog/ 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ /blog/$1 
RewriteCond %{HTTP_HOST} ^(.*\.)?mydomain\.org$ 
RewriteRule ^(/)?$ blog/index.php [L] 

各目录下安装的程序分别为:

\bbs Discuz
\blog Supersite+S-Space
\wp WordPress

有哪位能帮忙解决这个问题?当然我的意思是用htaccess解决。我的站点在虚拟主机上,只能用这个实现。 

谢谢了!

------解决方案--------------------
http://phprimer.com/viewtopic.php?f=23&t=453
发现我上面说错了 ,为了弥补,给你找了个文章,希望对你有用!
------解决方案--------------------
给你一个例子,其他同理,你参考一下

RewriteRule !\.(js|ico|gif|jpg|png|css)$ /wp/$1
RewriteRule ^(.*)$ /wp/$1

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template