作者grassboy2 (活力花俏草兒仔政﹞O花俏)
看板Web_Design
標題[問題] (不再鬼打牆) mod_rewrite 的問題…
時間Fri Dec 10 11:41:16 2010
---------不好意思,先前程式出了一點問題,以下為修正後的版本0rz----------
嗯嗯~事情是如此的…
假設今天我有很多個url是指到同一個ip的
例如
dns1.grassboy2.com
dns2.grassboy2.com
dns3.grassboy2.com
:
:
然後我的主機會根據不同的url會去作mod_rewrite
我希望只要host是dns1.grassboy.com的
全都導到網站根目錄下的dns1資料夾
也就是說…
http://dns1.grassboy2.com/dir1/index.php
會導到
http://dns1.grassboy2.com/dns1/dir1/index.php
我在網路上有查了一下…
應該會在.htaccess下加上下面幾行:
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^dns1.grassboy2.com$ [NC]
RewriteCond %{QUERY_STRING} ^$ [NC]
RewriteRule ^(.*)$ dns1/$1 [NC]
現在問題來了…
如果我網站根目錄下已經有一個dir1資料夾…
http://dns1.grassboy2.com/dir1/index.php
似乎是會優先指到 /dir1/index.php 而非 /dns1/dir1/index.php
請問有辦法藉由純修改.htaccess的方式去避免這狀況嗎?
也就是 dns1.grassboy2.com 無條件從 / 轉到 /dns1/ 下
先感謝大家的回答了 m(_ _)m
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.113.87.174
→ LewisHamiltn:Bang!還不錯玩 我也滿喜歡的 12/10 12:02
→ chrisQQ:其實我認真的瞭解到了zerox123456 (蒼流俊)是女僕控… 12/10 12:02
→ chrisQQ:看了應該有四百多次吧 12/10 12:03
→ opoepev:以為鬼打牆了~什麼鬼@@"直接把dns1的路徑指到/dns1下就行 12/10 12:09
→ TonyQ:......... 12/10 13:50
→ arrack:12樓的推文在? 12/10 20:17
推 s25g5d4:1 2樓...? 12/10 20:29
→ s25g5d4:靠 鬼打牆喔 什麼鬼 怎麼一直重複 還有怪文字 12/10 20:30
→ s25g5d4:太強了吧這個 12/10 20:30
推 loser5566:... 12/11 22:30
※ 編輯: grassboy2 來自: 140.113.87.174 (12/12 08:54)
※ 編輯: grassboy2 來自: 140.113.87.174 (12/12 08:55)
推 evernever:/dir1/ 底下是不是也有.htaccess override你根目錄的? 12/14 16:27