English 中文(简体)
转而提及现有主要内容
原标题:Redirect references to root to current alias instead

I m使用一个当地安装的Ap2.2.11,并在文件根面上安装了一个灯塔(alias localhost/fp/ =>/www/dirs/otherpages)。 我谨将“/favicon.ico”的请求转至 localhost/fp/favicon.ico,而不是 localhost/favicon.ico,在上有“htaccess file in Localhost/fp。 这是可能的,如果是的话,我如何这样做?

The reference to favicon.ico, would come from a file such as the following: /www/dirs/friendpages/test.htm (localhost/fp/test.htm) =>

<html>
    <head>
          <link href="/favicon.ico" rel="shortcut icon" type="image/x-icon">
    </head>
    <body>
          Page using favicon.ico
    </body>
</html>

我曾多次尝试使用《Rewrite规则》。 例如,

RewriteRule ^/favicon.ico$ /www/dirs/friendpages/favicon.ico

......但未能找到解决办法。 我似乎混淆了究竟是什么样子? 替代标准/编码。 我特别混淆了我如何制定《Rewrite规则》,对相对档案参考进行区分,例如通过上面的“链接标签”和“当地托管/fp/favicon.ico”等绝对字。 (后者显然不需要调整方向)。

我还利用我的<代码>d.conf进行了沉积。 档案:

RewriteLogLevel 9
RewriteLog /logs/rewrite.log

......但是,在装上上述表格时,我会发现:

127.0.0.1 - - [04/Nov/2011:05:09:51 --0700] [localhost/sid#14f44f8][rid#2619268/initial] (3) [perdir /www/dirs/friendpages/] strip per-dir prefix: /www/dirs/friendpages/test.htm -> test.htm
127.0.0.1 - - [04/Nov/2011:05:09:51 --0700] [localhost/sid#14f44f8][rid#2619268/initial] (3) [perdir /www/dirs/friendpages/] applying pattern  ^/favicon.ico$  to uri  test.htm 
127.0.0.1 - - [04/Nov/2011:05:09:51 --0700] [localhost/sid#14f44f8][rid#2619268/initial] (1) [perdir /www/dirs/friendpages/] pass through /www/dirs/friendpages/test.htm

我已经发现,实现预期结果的一种替代方式(缺乏适当参照本身)是建立一个虚拟的东道方(而不是简单地利用某个别处),但我的格乌托宁是,这也应当能够使用改观的再造和......。

问题回答

Your RewriteRule looks fine to me, I m not sure why it s not working. (You do have RewriteEngine on?)

既然已经将文件编号为/www/dirs/otherpages,也许你应该只是调整你的链接。

  1. Change it to a relative one:

    <link href="favicon.ico" rel="shortcut icon" type="image/x-icon">
    

    That will implicitly refer to /fp/favicon.ico.

  2. 2. 修改案文,明确提到/fp/favicon.ico:

    <link href="/fp/favicon.ico" rel="shortcut icon" type="image/x-icon">
    

无论是哪种方式,都指向/fp/favicon.ico,它将决心/www/dirs/otherpages/favicon.ico。 如果档案有的话,那么,你就不必再为它重新制定规则。

I agree that a virtual host is way overkill for this problem. A RewriteRule or correct href should be all you need to get your favicon.





相关问题
Using SimplePie with CodeIgniter and XAMPP

I am using CodeIgniter 1.7.2 with XAMPP 1.7.2 on a Windows computer. I am trying to make use of SimplePie. I followed all the instructions I could find: a copy of simplepie.inc is in my applications/...

Multiple Sites with common files

I have developed over 50 sites that all use the exact same files other than CSS and IMAGES, I currently duplicate the files each time I create a new site and upload different css and images. What ...

http server validation

I finish a litle http server, writing from scratch. I would like to be sure that my imlementation is conforme to the HTTP specifications. W3C give us tools for HTML/XML conformance, but i see nothing ...

热门标签