我想在Apache2.2.22(Debian 7)上使用PHP重写与PHP5.6-FPM,但我不会工作。 如果我通过.htaccess文件激活URL重写,我的服务器会抛出500错误(由于可能的配置错误,请求超过了10个内部重定向的限制。)
[Mon Oct 12 01:56:09 2015] [error] [client 93.232.122.47] 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., referer: ***********
[Mon Oct 12 01:56:09 2015] [debug] core.c(3116): [client 93.232.122.47] r->uri = /php5.fcgi/index.php, referer: ***********
[Mon Oct 12 01:56:09 2015] [debug] core.c(3122): [client 93.232.122.47] redirected from r->uri = /index.php, referer: ***********
[Mon Oct 12 01:56:09 2015] [debug] core.c(3122): [client 93.232.122.47] redirected from r->uri = /php5.fcgi/index.php, referer: ***********
[Mon Oct 12 01:56:09 2015] [debug] core.c(3122): [client 93.232.122.47] redirected from r->uri = /index.php, referer: ***********
[Mon Oct 12 01:56:09 2015] [debug] core.c(3122): [client 93.232.122.47] redirected from r->uri = /php5.fcgi/index.php, referer: ***********
[Mon Oct 12 01:56:09 2015] [debug] core.c(3122): [client 93.232.122.47] redirected from r->uri = /index.php, referer: ***********
[Mon Oct 12 01:56:09 2015] [debug] core.c(3122): [client 93.232.122.47] redirected from r->uri = /php5.fcgi/index.php, referer: ***********
[Mon Oct 12 01:56:09 2015] [debug] core.c(3122): [client 93.232.122.47] redirected from r->uri = /index.php, referer: ***********
[Mon Oct 12 01:56:09 2015] [debug] core.c(3122): [client 93.232.122.47] redirected from r->uri = /php5.fcgi/index.php, referer: ***********
[Mon Oct 12 01:56:09 2015] [debug] core.c(3122): [client 93.232.122.47] redirected from r->uri = /index.php, referer: ***********
[Mon Oct 12 01:56:09 2015] [debug] core.c(3122): [client 93.232.122.47] redirected from r->uri = /intern/, referer: ***********
[Mon Oct 12 01:56:09 2015] [debug] mod_deflate.c(700): [client 93.232.122.47] Zlib: Compressed 637 to 391 : URL /php5.fcgi/index.php, referer: ***********
的.htaccess
<IfModule mod_rewrite.c>
# Enable URL rewriting
RewriteEngine Off
# Store the current location in an environment variable CWD to use
# mod_rewrite in .htaccess files without knowing the RewriteBase
RewriteCond $0#%{REQUEST_URI} ([^#]*)#(.*)\1$
RewriteRule ^.*$ - [E=CWD:%2]
# Rule for versioned static files, configured through:
# - $GLOBALS['TYPO3_CONF_VARS']['BE']['versionNumberInFilename']
# - $GLOBALS['TYPO3_CONF_VARS']['FE']['versionNumberInFilename']
# IMPORTANT: This rule has to be the very first RewriteCond in order to work!
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)\.(\d+)\.(php|js|css|png|jpg|gif|gzip)$ $1.$3 [L]
# Access block for folders
RewriteRule _(?:recycler|temp)_/ - [F]
RewriteRule fileadmin/templates/.*\.(?:txt|ts)$ - [F]
RewriteRule typo3temp/logs/ - [F]
RewriteRule ^(vendor|typo3_src) - [F]
RewriteRule (?:typo3conf/ext|typo3/sysext|typo3/ext)/[^/]+/(?:Configuration|Resources/Private|Tests?)/ - [F]
# Access block for files or folders starting with a dot
RewriteCond %{SCRIPT_FILENAME} -d [OR]
RewriteCond %{SCRIPT_FILENAME} -f
RewriteRule (?:^|/)\. - [F]
# Stop rewrite processing, if we are in the typo3/ directory or any other known directory
# NOTE: Add your additional local storages here
RewriteRule (?:typo3/|fileadmin/|typo3conf/|typo3temp/|uploads/|favicon\.ico) - [L]
# If the file/symlink/directory does not exist => Redirect to index.php.
# For httpd.conf, you need to prefix each '%{REQUEST_FILENAME}' with '%{DOCUMENT_ROOT}'.
#RewriteCond %{REQUEST_URI} !^/fastcgiphp/*
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^.*$ %{ENV:CWD}index.php [QSA,L]
</IfModule>
虚拟主机:
<VirtualHost *:80>
AddHandler php5-fcgi .php
Action php5-fcgi /php5.fcgi
Alias /php5-fcgi /var/www/php5-fcgi
FastCgiExternalServer /var/www/php5.fcgi -socket /var/run/php5-fpm.sock -pass-header Authorization
ServerAdmin webmaster@localhost
DocumentRoot /var/www
#<Directory />
# Options FollowSymLinks
# AllowOverride none
#</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride FileInfo AuthConfig Limit Indexes Options
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel debug
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
答案 0 :(得分:0)
尝试更改最后RewriteRule
行:
RewriteRule ^.*$ %{ENV:CWD}index.php [QSA,L]
到此:
RewriteRule !index\.php index.php [NC,L]
并重新测试。