繁体   English   中英

URL 在 apache2 上用 php5-fpm 重写

[英]URL rewrites with php5-fpm on apache2

我想在 Apache2.2.22 (Debian 7) 上使用 PHP5.6-FPM 重写 URL,但我不会工作。 如果我通过 .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>

尝试更改最后的RewriteRule行:

RewriteRule ^.*$ %{ENV:CWD}index.php [QSA,L]

对此:

RewriteRule !index\.php index.php [NC,L]

和休息。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM