Apache 简单模式重写重定向不起作用
您好,我正在尝试编写一个mod rewrite,将/example重定向到/example.php。代码看起来应该正常工作,但实际情况并非如此:Apache 简单模式重写重定向不起作用,apache,mod-rewrite,Apache,Mod Rewrite,您好,我正在尝试编写一个mod rewrite,将/example重定向到/example.php。代码看起来应该正常工作,但实际情况并非如此: Options +FollowSymLinks RewriteEngine On RewriteCond %{SCRIPT_FILENAME} !-d RewriteCond %{SCRIPT_FILENAME} !-f RewriteRule ^([a-z]+)/$ /$1.php 错误日志文件: [Mon Nov 21 04:13:27 20
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^([a-z]+)/$ /$1.php
错误日志文件:
[Mon Nov 21 04:13:27 2011] [error] [client 109.149.215.195] 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.
[Mon Nov 21 04:13:31 2011] [error] [client 109.149.215.195] 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.
[Mon Nov 21 08:26:23 2011] [error] [client 109.149.215.195] Negotiation: discovered file(s) matching request: /var/chroot/home/content/86/8128686/html/college (None could be negotiated).
[Wed Nov 23 16:33:55 2011] [alert] [client 109.149.215.195] /var/chroot/home/content/86/8128686/html/.htaccess: RewriteLog not allowed here
[Wed Nov 23 16:43:23 2011] [error] [client 109.149.215.195] File does not exist: /var/chroot/home/content/86/8128686/html/missing.html
[Wed Nov 23 16:43:39 2011] [error] [client 109.149.215.195] Negotiation: discovered file(s) matching request: /var/chroot/home/content/86/8128686/html/index (None could be negotiated).
[Wed Nov 23 16:43:39 2011] [error] [client 109.149.215.195] File does not exist: /var/chroot/home/content/86/8128686/html/missing.html
[Thu Nov 24 02:46:47 2011] [error] [client 69.58.178.58] Directory index forbidden by Options directive: /var/chroot/home/content/86/8128686/html/uploads/
[Thu Nov 24 02:46:47 2011] [error] [client 69.58.178.58] File does not exist: /var/chroot/home/content/86/8128686/html/missing.html
提前感谢首先,我的建议是: 请尝试使用
RewriteLog
指令:它可以帮助您跟踪此类问题:
# Trace:
# (!) file gets big quickly, remove in prod environments:
RewriteLog "/web/logs/mywebsite.rewrite.log"
RewriteLogLevel 9
RewriteEngine On
然后,解决方案是:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^([a-z]+)$ /$1.php [QSA,L]
告诉我它是否有效。首先,我的建议是: 请尝试使用
RewriteLog
指令:它可以帮助您跟踪此类问题:
# Trace:
# (!) file gets big quickly, remove in prod environments:
RewriteLog "/web/logs/mywebsite.rewrite.log"
RewriteLogLevel 9
RewriteEngine On
然后,解决方案是:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^([a-z]+)$ /$1.php [QSA,L]
告诉我它是否有效。为什么不起作用?你的错误是什么?会发生什么?什么事情没有发生?日志上写着什么?mod_rewrite启用了吗?@JanDragsbaek我不知道为什么它不起作用,因此问题是,我找不到404,我应该在日志中查找什么,是,mod rewrite已启用。@JanDragsbaek:LOL:始终是相同的问题,始终是不想自己搜索的人。。。你今天过得不好吗?;)@OlivierPons是的,有一点:D@OlivierPons我已经搜索过了,但是我对mod rewrite还很陌生,代码看起来应该可以工作。。。。我想你知道它怎么了?为什么不工作?你的错误是什么?会发生什么?什么事情没有发生?日志上写着什么?mod_rewrite启用了吗?@JanDragsbaek我不知道为什么它不起作用,因此问题是,我找不到404,我应该在日志中查找什么,是,mod rewrite已启用。@JanDragsbaek:LOL:始终是相同的问题,始终是不想自己搜索的人。。。你今天过得不好吗?;)@OlivierPons是的,有一点:D@OlivierPons我已经搜索过了,但是我对mod rewrite还很陌生,代码看起来应该可以工作。。。。我想你知道它出了什么问题吗?单独使用解决方案不起作用(像以前一样提出404)。添加rewritelog指令导致整个站点出现500错误(我确实更新了日志路径)。仅仅添加rewritelog指令不可能导致500错误。您的整个配置存在问题,不仅仅是重写规则。您是否创建了真正的vhost,即
和
之间的指令?在此vhost中,您是否使用DocumentRoot
、ServerName
和ServerAlias
创建了真正的本地服务器?您是否根据您的ServerName
更改了您的/etc/hosts
,以便您可以键入服务器名称并将其指向您的PC?您好,我现在正在使用godaddy web hosting(我知道),因此上述内容都没有。我看过godaddy的支持,他们说mon_rewrite已经启用,应该可以按预期工作。嗯,这很奇怪。它加载php文档的链接css文件。单独使用解决方案不起作用(像以前一样使用404)。添加rewritelog指令导致整个站点出现500错误(我确实更新了日志路径)。仅仅添加rewritelog指令不可能导致500错误。您的整个配置存在问题,不仅仅是重写规则。您是否创建了真正的vhost,即
和
之间的指令?在此vhost中,您是否使用DocumentRoot
、ServerName
和ServerAlias
创建了真正的本地服务器?您是否根据您的ServerName
更改了您的/etc/hosts
,以便您可以键入服务器名称并将其指向您的PC?您好,我现在正在使用godaddy web hosting(我知道),因此上述内容都没有。我看过godaddy的支持,他们说mon_rewrite已经启用,应该可以按预期工作。嗯,这很奇怪。它加载php文档的链接css文件。