問題:使用Kohana的/PHP開發其他公司託管網站使用APACHE RewriteRule不會覆蓋REQUEST_URI嗎?
上午。 我讓客戶在他們的DNS服務器中輸入CNAME條目以指向我的域名。例如。 http://invites.somecompany.com指向http://www.mydomain.com。
因此,%{HTTP_HOST}我的Apache服務器上的條目是 'invites.somecompany.com'
我想重寫http://invites.somecompany.com/invite到http://www.mydomain.com/invites/invite
即使阿帕奇似乎這樣做, $ _SERVER ['REQUEST_URI']仍然是「/」。 問題是Kohana使用$ _SERVER ['REQUEST_URI']將請求路由到相應的控制器代碼。在這種情況下,它將它路由到基地索引控制器,而不是'邀請'控制器。
事實:
Apache的mod_rewrite的指令,我使用(在.htaccess文件): -
RewriteCond %{HTTP_HOST} !^www.mydomain.com$
RewriteCond %{REQUEST_URI} !.*invites.*
RewriteRule ^(.*)$ invites/$1
# For Kohana
RewriteRule .* index.php?kohana_uri=$0 [PT,QSA,L]
在index.php
,我做的:
var_dump($_SERVER);
我得到:
'REQUEST_URI' => string '/',
'QUERY_STRING' => string 'kohana_uri=invites/index.php&kohana_uri=invites/invite'
'REDIRECT_QUERY_STRING' => string 'kohana_uri=invites/invite'
所以mod_rewrite不會修改REQUEST_URI?
極品:
'REQUEST_URI' => 'invites/invite',
'QUERY_STRING' => string 'kohana_uri=invites/invite',
如何獲得呢?
====================== 編輯
重寫日誌條目: -
strip per-dir prefix: /Users/project/invite -> invite
applying pattern '^(?:application|modules|system)\b.*' to uri 'invite'
strip per-dir prefix: /Users/project/invite -> invite
applying pattern '\.git' to uri 'invite'
strip per-dir prefix: /Users/project/invite -> invite
applying pattern '^(.*)$' to uri 'invite'
rewrite invite -> invites/invite
add per-dir prefix: invites/invite -> /Users/project/invites/invite
strip per-dir prefix: /Users/project/invites/invite -> invites/invite
applying pattern '.*' to uri 'invites/invite'
rewrite invites/invite -> index.php?kohana_uri=invites/invite
add per-dir prefix: index.php -> /Users/project/index.php
strip document_root prefix: /Users/project/index.php -> /index.php
internal redirect with /index.php [INTERNAL REDIRECT]
strip per-dir prefix: /Users/project/index.php -> index.php
applying pattern '^(?:application|modules|system)\b.*' to uri 'index.php'
strip per-dir prefix: /Users/project/index.php -> index.php
applying pattern '\.git' to uri 'index.php'
strip per-dir prefix: /Users/project/index.php -> index.php
applying pattern '^(.*)$' to uri 'index.php'
rewrite index.php -> invites/index.php
add per-dir prefix: invites/index.php -> /Users/project/invites/index.php
strip per-dir prefix: /Users/project/invites/index.php -> invites/index.php
applying pattern '.*' to uri 'invites/index.php'
rewrite invites/index.php -> index.php?kohana_uri=invites/index.php
add per-dir prefix: index.php -> /Users/project/index.php
initial URL equal rewritten URL: /Users/project/index.php [IGNORING REWRITE]
那是怎樣的mod_rewrite的作品。 – zerkms 2011-05-03 04:20:47
hmmmmmmmmmmmmmm – Ajoy 2011-05-03 04:26:25