2012-05-18 53 views
1

我有一個VServer在這裏,我在/ var/www /,腳本 在/ var /客戶/網/ web001 /的其他常見的東西,一些管理的應用程式。的mod_rewrite達到LimitInternalRecursion

我想打一個重定向所有不存在的文件和目錄

  /var/www/ -> /var/customers/webs/web001/ 

,這樣我可以使用域名根和web001客戶。

我不確定實現這一目標的最佳方法是什麼。 我嘗試使用mod_rewrite,但有內部重定向到達遞歸限制。

我在做什麼錯了?

htaccess的

  # allow psydo-location (not existing folder) 
      Options +FollowSymLinks 

      # Turn on URL rewriting engine 
      RewriteEngine On 

      # Folder of this htaccess-file in not root-folder 
      RewriteBase /var/www/ 

      # Disable rewriting for existing files or directories 
      RewriteCond %{REQUEST_FILENAME} !-f 
      RewriteCond %{REQUEST_FILENAME} !-d 
      RewriteCond %{REQUEST_FILENAME} !^/var/customers/webs/web001/ 

      # redirect all other requests to index.php 
      rewriteRule ^.*$ /var/customers/webs/web001/index.php [DPI,L] 

的apache2/error.log中

  Request exceeded the limit of 10 internal redirects 
      due to probable configuration error. 
      Use 'LimitInternalRecursion' to increase the limit if necessary. 
      Use 'LogLevel debug' to get a backtrace. 
      redirected from r->uri = /var/customers/webs/web001/index.php 
      redirected from r->uri = /var/customers/webs/web001/index.php 
      redirected from r->uri = /var/customers/webs/web001/index.php 
      redirected from r->uri = /var/customers/webs/web001/index.php 
      redirected from r->uri = /var/customers/webs/web001/index.php 
      redirected from r->uri = /var/customers/webs/web001/index.php 
      redirected from r->uri = /var/customers/webs/web001/index.php 
      redirected from r->uri = /var/customers/webs/web001/index.php 
      redirected from r->uri = /var/customers/webs/web001/index.php 
      redirected from r->uri = /index.php 

rewrite.log

  (3) [perdir /var/www/] strip per-dir prefix: /var/www/index.php -> index.php 
      (3) [perdir /var/www/] applying pattern '^.*$' to uri 'index.php' 
      (4) [perdir /var/www/] RewriteCond: input='/var/www/index.php' pattern='!-f' => matched 
      (4) [perdir /var/www/] RewriteCond: input='/var/www/index.php' pattern='!-d' => matched 
      (4) [perdir /var/www/] RewriteCond: input='/var/www/index.php' pattern='!^/var/customers/webs/web001/' => matched 
      (2) [perdir /var/www/] rewrite 'index.php' -> '/var/customers/webs/web001/index.php' 
      (2) [perdir /var/www/] trying to replace prefix /var/www/ with /var/www/ 
      (1) [perdir /var/www/] internal redirect with /var/customers/webs/web001/index.php [INTERNAL REDIRECT] 
      (3) [perdir /var/www/] add path info postfix: /var/www/var -> /var/www/var/customers/webs/web001/index.php 
+0

RewriteBase應該是相對於文檔根,而不是文件系統根。所以它應該只是'RewriteBase /'。你也不能重定向到DocumentRoot之外的文件,因爲Apache不允許它。 – Gerben

+0

那麼我的問題應該是:在哪裏,我應該爲了通過請求同一個域,以獲得文件系統文件夾的內容「/無功/網絡/」和「在/ var /客戶/網/ web001 /」調整? –

+0

我不認爲你可以。 – Gerben

回答

1

確定。我找到了解決方案。 它不在.htaccess中,而是在httpd.conf中。 隨着DocumentRoot的適當的設置,幾乎所有的請求將被交付形式在/ var /客戶/網/ web001 /, 除了這些誰將會被排除別名-指令。

的/etc/apache2/httpd.conf外觀類似的東西:

  #NameVirtualHost SERVER_IP:PORT 
      <VirtualHost SERVER_IP:PORT> 
       ServerName SERVER_IP 
       ServerAlias DOMAIN.TLD 

       # instead of DocumentRoot "/var/www/" 
       DocumentRoot "/var/customers/webs/web001/" 

       # add Aliases for each Application in the /var/www 
       Alias /URL_SUB_PATH_APP_1 "/var/www/URL_SUB_PATH_APP_1" 
       Alias /URL_SUB_PATH_APP_2 "/var/www/URL_SUB_PATH_APP_2" 
      </VirtualHost> 

      Include /etc/apache2/vhosts.conf 

像戈說和.htaccess文件是爲了這個目的沒有幫助。