문제 : 다른 회사에 대한 호스팅 웹 사이트를 개발하는 Kohana/PHP를 사용하여APACHE RewriteRule을 사용하여 REQUEST_URI를 재정의하지 않습니까?
입니다. 고객이 DNS 서버의 CNAME 항목에 내 도메인을 가리 키도록합니다. 예 : http://invites.somecompany.com은 http://www.mydomain.com을 가리 킵니다.
따라서, 내 아파치 서버의 % {HTTP_HOST} 항목은 'invites.somecompany.com'
나는 아파치가 그 일을 할 것 같다 비록 http://invites.somecompany.com/invite http://www.mydomain.com/invites/invite에을 다시 할
, $ _SERVER [ 'REQUEST_URI']는 여전히 "/"입니다. Kohana는 $ _SERVER [ 'REQUEST_URI']을 사용하여 해당 컨트롤러 코드로 요청을 라우팅합니다. 이 경우 '초대 관리자'컨트롤러 대신 베이스 색인 컨트롤러로 라우팅됩니다.
현황 : 내가 (htaccess로 파일에) 사용하고
아파치 mod_rewrite를 지시 : -의 index.php에서
RewriteCond %{HTTP_HOST} !^www.mydomain.com$
RewriteCond %{REQUEST_URI} !.*invites.*
RewriteRule ^(.*)$ invites/$1
# For Kohana
RewriteRule .* index.php?kohana_uri=$0 [PT,QSA,L]
, 내가 할 :
var_dump($_SERVER);
및 i :
'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
hmmmmmmmmmmmmmm – Ajoy