我正在尝试把我的门户和我的网站整合起来。
我的网站:
http://example.com我的门户:
http://portal.com现在我想看看我的门户网站:
http://example.com/portal我的核心apache配置文件的一部分(支持站点/网站):
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName example.com
DocumentRoot /home/example/WebSite2.0/WebContent
DirectoryIndex index.php index.html
<Directory /home/example/WebSite2.0/WebContent>
Options +IncludesNOEXEC
AllowOverride None
Order allow,deny
allow from all
XBitHack On
AddType text/html .html
AddHandler server-parsed .html
</Directory>
Alias /portal /home/example/portal/CodeIgniter_2.1.0
<Directory /home/example/portal/CodeIgniter_2.1.0>
DirectoryIndex "index.php"
allow from all
Options +Indexes
#Options FollowSymLinks MultiViews
Order allow,deny
RewriteEngine On
RewriteBase /portal
#RewriteRule ^test\.html$ test.php
RewriteCond $1 !^(index\.php|css|images|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
RewriteCond $1 ^(css|images|js)
RewriteRule ^(.*)$ $1
</Directory>
</VirtualHost>正如您所看到的,我的门户函数在CodeIgniter之上;因此-
RewriteCond $1 !^(index\.php|css|images|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]我的核心apache配置文件(支持站点/门户)的一部分:
<VirtualHost *:443>
ServerAdmin webmaster@localhost
ServerName portal.com
ServerAlias www.portal.com
DocumentRoot /home/example/portal/CodeIgniter_2.1.0
DirectoryIndex "index.php"
SSLEngine On
SSLCertificateFile "ssl/portal.com.crt"
SSLCertificateKeyFile "ssl/portal.com.key"
<Directory /home/example/portal/CodeIgniter_2.1.0>
Options FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
Header unset Server
ServerSignature Off
</Directory>
</VirtualHost>现在真正的问题是,当我打开http://example.com/portal时,浏览器是在DocumentRoot而不是Alias中查找图像。
例如门户网站上的图像,
<img src="/images/example.png" style="margin-left:30px;height:50px;">apache错误日志上写着-
File does not exist: /home/example/WebSite2.0/WebContent/images/example.png我不想修改我的代码。我只想让这个东西从apache配置文件本身开始工作。请帮我做这个。
发布于 2013-09-10 06:47:33
RewriteBase /portal要求url以/portal开头。所以:
RewriteCond $1 !^(index\.php|css|images|robots\.txt)不会被击中。
<img src="/images/example.png" style="margin-left:30px;height:50px;">将尝试从DocumentRoot搜索文件。
update1
由于有RewriteBase /portal,example.com/portal/images将命中重写规则,但example.com/images不会,因此:
<img src="/images/example.png" style="margin-left:30px;height:50px;">应:
<img src="/portal/images/example.png" style="margin-left:30px;height:50px;">update2
这是@Hussain Tamboli本人给出的答复:
RewriteRule /(images|js|css)/(.+)\.(.+)$ /portal/$1/$2.$3 [PT]./images/Invoice.png将重写为/portal/images/Invoice.png
https://stackoverflow.com/questions/18711695
复制相似问题