문제

우리가 가진 drupal에 대한 mod_rewrite 표현에서 매우 빠른 수정이 필요합니다.

  RewriteCond %{REQUEST_URI} !(\.gif)|(\.jpg)|(\.png)|(\.css)|(\.js)|(\.php)$ 
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} !=/favicon.ico
  RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

그러나 나는 sub 도메인의 값을 Get Too 도로 리디렉션해야하므로 다음과 같이 줄 무언가가 필요합니다.

  RewriteCond %{REQUEST_URI} !(\.gif)|(\.jpg)|(\.png)|(\.css)|(\.js)|(\.php)$ 
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} !=/favicon.ico
  RewriteRule ^(.*)$ index.php?subdomain=THE SUBDOMAIN HERE&q=$1 [L,QSA]

어떻게 해야할지 모르겠습니다. 도와주세요!

도움이 되었습니까?

해결책

이것을 다시 시도하면, 어떤 이유로 내 코드가 제대로 렌더링되지 않습니다.

RewriteCond %{REQUEST_URI} !(\.gif)|(\.jpg)|(\.png)|(\.css)|(\.js)|(\.php)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteCond %{HTTP_HOST} ^(.*)\.mydomain\.com$
RewriteRule ^(.*) index.php?subdomain=%1&q=1 [L,QSA]

내가 찾은 일부 포럼 게시물을 기반으로합니다 여기.

다른 팁

쿼리 문자열에서 하위 도메인이 실제로 필요하지 않습니다.

하위 도메인은 $ _server [ 'server_name']에서 php에서 찾을 수 있습니다.

PHP 문서 말 :

'SERVER_NAME'
    The name of the server host under which the
    current script is executing. If the script
    is running on a virtual host, this will be
    the value defined for that virtual host. 
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top