你好,我今天一直在用我的新家庭服务器苦苦挣扎。我已经安装了最新版本的ubuntu服务器。安装了php,apache,mysql,一切似乎都很完美。
我正在尝试在我的本地计算机上建立一个与XAMPP完美配合的网站。我一直在使用本指南来设置mod_rewrite。 http://www.solutionsamir.com/20110303140/Operating-Systems/Linux-Unix/How-to-enable-mod_rewrite-on-ubuntu-server-for-apache2.html
这是我的HTACCESS
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/?index.php$
RewriteRule . index.php
这是我的000默认值 ` ServerAdmin webmaster @ localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride all
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride all
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 warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride all
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
`
它以某种方式工作,但每次我发布一个表单,我得到500内部服务器错误。任何想法都错了吗?
编辑:这是我通过激活日志记录获得的。
192.168.1.110 - - [04/Apr/2012:23:41:22 +0200] [192.168.1.233/sid#7f52893ad1d8][rid#7f528923b0a0/initial] (3) [perdir /var/www/serverpanel/] add path info postfix: /var/www/serverpanel/login -> /var/www/serverpanel/login/
192.168.1.110 - - [04/Apr/2012:23:41:22 +0200] [192.168.1.233/sid#7f52893ad1d8][rid#7f528923b0a0/initial] (3) [perdir /var/www/serverpanel/] strip per-dir prefix: /var/www/serverpanel/login/ -> login/
192.168.1.110 - - [04/Apr/2012:23:41:22 +0200] [192.168.1.233/sid#7f52893ad1d8][rid#7f528923b0a0/initial] (3) [perdir /var/www/serverpanel/] applying pattern '^(.+)/$' to uri 'login/'
192.168.1.110 - - [04/Apr/2012:23:41:22 +0200] [192.168.1.233/sid#7f52893ad1d8][rid#7f528923b0a0/initial] (2) [perdir /var/www/serverpanel/] rewrite 'login/' -> 'index.php'
192.168.1.110 - - [04/Apr/2012:23:41:22 +0200] [192.168.1.233/sid#7f52893ad1d8][rid#7f528923b0a0/initial] (3) [perdir /var/www/serverpanel/] add per-dir prefix: index.php -> /var/www/serverpanel/index.php
192.168.1.110 - - [04/Apr/2012:23:41:22 +0200] [192.168.1.233/sid#7f52893ad1d8][rid#7f528923b0a0/initial] (2) [perdir /var/www/serverpanel/] strip document_root prefix: /var/www/serverpanel/index.php -> /serverpanel/index.php
192.168.1.110 - - [04/Apr/2012:23:41:22 +0200] [192.168.1.233/sid#7f52893ad1d8][rid#7f528923b0a0/initial] (1) [perdir /var/www/serverpanel/] internal redirect with /serverpanel/index.php [INTERNAL REDIRECT]
192.168.1.110 - - [04/Apr/2012:23:41:22 +0200] [192.168.1.233/sid#7f52893ad1d8][rid#7f5289230208/initial/redir#1] (3) [perdir /var/www/serverpanel/] strip per-dir prefix: /var/www/serverpanel/index.php -> index.php
192.168.1.110 - - [04/Apr/2012:23:41:22 +0200] [192.168.1.233/sid#7f52893ad1d8][rid#7f5289230208/initial/redir#1] (3) [perdir /var/www/serverpanel/] applying pattern '^(.+)/$' to uri 'index.php'
192.168.1.110 - - [04/Apr/2012:23:41:22 +0200] [192.168.1.233/sid#7f52893ad1d8][rid#7f5289230208/initial/redir#1] (1) [perdir /var/www/serverpanel/] pass through /var/www/serverpanel/index.php
192.168.1.110 - - [04/Apr/2012:23:41:52 +0200] [192.168.1.233/sid#7f52893ad1d8][rid#7f528923b0a0/initial] (3) [perdir /var/www/serverpanel/] add path info postfix: /var/www/serverpanel/login -> /var/www/serverpanel/login/
192.168.1.110 - - [04/Apr/2012:23:41:52 +0200] [192.168.1.233/sid#7f52893ad1d8][rid#7f528923b0a0/initial] (3) [perdir /var/www/serverpanel/] strip per-dir prefix: /var/www/serverpanel/login/ -> login/
192.168.1.110 - - [04/Apr/2012:23:41:52 +0200] [192.168.1.233/sid#7f52893ad1d8][rid#7f528923b0a0/initial] (3) [perdir /var/www/serverpanel/] applying pattern '^(.+)/$' to uri 'login/'
192.168.1.110 - - [04/Apr/2012:23:41:52 +0200] [192.168.1.233/sid#7f52893ad1d8][rid#7f528923b0a0/initial] (2) [perdir /var/www/serverpanel/] rewrite 'login/' -> 'index.php'
192.168.1.110 - - [04/Apr/2012:23:41:52 +0200] [192.168.1.233/sid#7f52893ad1d8][rid#7f528923b0a0/initial] (3) [perdir /var/www/serverpanel/] add per-dir prefix: index.php -> /var/www/serverpanel/index.php
192.168.1.110 - - [04/Apr/2012:23:41:52 +0200] [192.168.1.233/sid#7f52893ad1d8][rid#7f528923b0a0/initial] (2) [perdir /var/www/serverpanel/] strip document_root prefix: /var/www/serverpanel/index.php -> /serverpanel/index.php
192.168.1.110 - - [04/Apr/2012:23:41:52 +0200] [192.168.1.233/sid#7f52893ad1d8][rid#7f528923b0a0/initial] (1) [perdir /var/www/serverpanel/] internal redirect with /serverpanel/index.php [INTERNAL REDIRECT]
192.168.1.110 - - [04/Apr/2012:23:41:52 +0200] [192.168.1.233/sid#7f52893ad1d8][rid#7f52892304b8/initial/redir#1] (3) [perdir /var/www/serverpanel/] strip per-dir prefix: /var/www/serverpanel/index.php -> index.php
192.168.1.110 - - [04/Apr/2012:23:41:52 +0200] [192.168.1.233/sid#7f52893ad1d8][rid#7f52892304b8/initial/redir#1] (3) [perdir /var/www/serverpanel/] applying pattern '^(.+)/$' to uri 'index.php'
192.168.1.110 - - [04/Apr/2012:23:41:52 +0200] [192.168.1.233/sid#7f52893ad1d8][rid#7f52892304b8/initial/redir#1] (1) [perdir /var/www/serverpanel/] pass through /var/www/serverpanel/index.php
答案 0 :(得分:1)
很好的问题,有了日志。值得关注 ;)
我可以看到,您正在尝试连接到您的本地网址login/
。
完成重写规则,最后是
/var/www/serverpanel/index.php -> /serverpanel/index.php
将其重定向到另一个网址(不使用实际的Php)/serverpanel/index.php
。
因此它尝试再次应用规则,但使用/serverpanel/index.php
。
正如你猜测的那样,它将被重写为index.php
,从而进行无限循环。
仔细查看您的日志:
(1) [perdir /var/www/serverpanel/] internal redirect with /serverpanel/index.php [INTERNAL REDIRECT]
这可能是您解决方案的关键:perdir /var/www/serverpanel/
2个问题:
.htaccess
个文件吗?.htaccess
,请尝试检查所有您的Apache配置文件,查找
与<Directory "xxx">
有关的/var/www/serverpanel/
指令,您可能会发现问题所在。希望这有帮助