2014-01-10 24 views
0

我的網站上的所有內容都可以工作(Drupal PHP),除了訪問已經上傳到服務器的文件。它們駐留在/ sites/default/files /中。我從/刪除我的.htaccess文件的網站/默認/文件/當我嘗試訪問位於該目錄中的文件,我得到:在Apache服務器上直接訪問PDF時,請求超過了10個內部重定向的限制

[Thu Jan 09 21:59:05 2014] [error] [client x.x.x.x] 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. 

我的虛擬主機在我的httpd.conf文件中定義爲例如:

<VirtualHost *:80> 
DocumentRoot "/var/www/html/home" 
<Directory "/var/www/html/home"> 
allow from all 
Options +Indexes 
</Directory> 
</VirtualHost> 

而且上面,有一個「目錄」定義爲這樣的:

<Directory /> 
Options FollowSymLinks 
AllowOverride All 
</Directory> 

<Directory "/var/www/html"> 
Options Includes FollowSymLinks 
AllowOverride All 
Order allow,deny 
Allow from all 
</Directory> 

我真的不知道從哪裏何去何從。我在stackoverflow上找到的其他東西都引用了重寫,但在我看來,我只是試圖直接訪問文件,沒有魔法,沒有引用,重寫或什麼 - 你。


編輯:

這是.htacess文件,我發現在/ var/www/html等:

# 
# Apache/PHP/Drupal settings: 
# 

# Protect files and directories from prying eyes. 
<FilesMatch "\.(engine|inc|info|install|module|profile|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(code-style\.pl|Entries.*|Repository|Root|Tag|Template)$"> 
    Order allow,deny 
</FilesMatch> 

# Don't show directory listings for URLs which map to a directory. 
Options -Indexes 

# Follow symbolic links in this directory. 
Options +FollowSymLinks 

# Make Drupal handle any 404 errors. 
ErrorDocument 404 /index.php 

# Force simple error message for requests for non-existent favicon.ico. 
<Files favicon.ico> 
    ErrorDocument 404 "The requested file favicon.ico was not found. 
</Files> 

# Set the default handler. 
DirectoryIndex index.php 

# Override PHP settings. More in sites/default/settings.php 
# but the following cannot be changed at runtime. 

# PHP 4, Apache 1. 
<IfModule mod_php4.c> 
    php_value magic_quotes_gpc    0 
    php_value register_globals    0 
    php_value session.auto_start    0 
    php_value mbstring.http_input    pass 
    php_value mbstring.http_output   pass 
    php_value mbstring.encoding_translation 0 
</IfModule> 

# PHP 4, Apache 2. 
<IfModule sapi_apache2.c> 
    php_value magic_quotes_gpc    0 
    php_value register_globals    0 
    php_value session.auto_start    0 
    php_value mbstring.http_input    pass 
    php_value mbstring.http_output   pass 
    php_value mbstring.encoding_translation 0 
</IfModule> 

# PHP 5, Apache 1 and 2. 
<IfModule mod_php5.c> 
    php_value magic_quotes_gpc    0 
    php_value register_globals    0 
    php_value session.auto_start    0 
    php_value mbstring.http_input    pass 
    php_value mbstring.http_output   pass 
    php_value mbstring.encoding_translation 0 
</IfModule> 

# Requires mod_expires to be enabled. 
<IfModule mod_expires.c> 
    # Enable expirations. 
    ExpiresActive On 

    # Cache all files for 2 weeks after access (A). 
    ExpiresDefault A1209600 

    # Do not cache dynamically generated pages. 
    ExpiresByType text/html A1 
</IfModule> 

# Various rewrite rules. 
<IfModule mod_rewrite.c> 
    RewriteEngine on 

    # If your site can be accessed both with and without the 'www.' prefix, you 
    # can use one of the following settings to redirect users to your preferred 
    # URL, either WITH or WITHOUT the 'www.' prefix. Choose ONLY one option: 
    # 
    # To redirect all users to access the site WITH the 'www.' prefix, 
    # (http://example.com/... will be redirected to http://www.example.com/...) 
    # adapt and uncomment the following: 
    # RewriteCond %{HTTP_HOST} ^example\.com$ [NC] 
    # RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301] 
    # 
    # To redirect all users to access the site WITHOUT the 'www.' prefix, 
    # (http://www.example.com/... will be redirected to http://example.com/...) 
    # uncomment and adapt the following: 
    # RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC] 
    # RewriteRule ^(.*)$ http://example.com/$1 [L,R=301] 

    # Modify the RewriteBase if you are using Drupal in a subdirectory or in a 
    # VirtualDocumentRoot and the rewrite rules are not working properly. 
    # For example if your site is at http://example.com/drupal uncomment and 
    # modify the following line: 
    # RewriteBase /drupal 
    # 
    # If your site is running in a VirtualDocumentRoot at http://example.com/, 
    # uncomment the following line: 
    # RewriteBase/

    # Rewrite URLs of the form 'x' to the form 'index.php?q=x'. 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond %{REQUEST_URI} !=/favicon.ico 
    RewriteRule ^(.*)$ index.php?q=$1 [L,QSA] 
</IfModule> 

# $Id: .htaccess,v 1.90.2.1 2008/07/08 09:33:14 goba Exp $ 

回答

0

如果在一個htaccess文件的任何父目錄,這些規則將被應用,甚至可能直接訪問那裏的文件。爲避免mod_rewrite規則在目錄中得到應用,你可以做的一件事是在目錄中啓用mod rewrite並且沒有規則。例如,簡單地說:

RewriteEngine On 

/sites/default/files/目錄中。

+0

那麼,對於那些不存在的文件,我現在得到一個不錯的404頁面。但是,對於那裏的文件,結果相同 - 請求超出了10個內部重定向的限制。如果我直接訪問URL,什麼是重定向?顯然有一些交接或一些事情正在發生? – harperville

+0

@harperville在父目錄中的htaccess文件中是否有規則? –

+0

/sites/default/files/ – harperville

相關問題