htaccess 重写给我 500 错误?

发布于 2024-09-27 04:42:58 字数 721 浏览 0 评论 0原文

我有一个我想使其友好的网址,在 .htacess 上使用重写,但它给了我一个错误(500内部服务器错误),这是我原来的php网址

http://www.example.com/viewtopic.php?topic=lovetopic

我想将其更改为:

http://www.example.com/lovetopic

这是我的整个htaccess代码是这:

RewriteEngine On
RewriteRule ^user/([^/]*)$ /viewprofile.php?user=$1 [L]
RewriteRule ^([^/]*)$ /viewtopic.php?topic=$1 [L]

我不知道问题是什么

编辑服务器错误日志给了我这个错误

[Thu Oct 14 20:34:36 2010] [error] 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., 

i have this url that i wanted to make friendly, using rewrite on .htacess but it gives me an error(500 internal server error), this is my orginal php url

http://www.example.com/viewtopic.php?topic=lovetopic

i want to change it to this:

http://www.example.com/lovetopic

this is my whole htaccess code is this:

RewriteEngine On
RewriteRule ^user/([^/]*)$ /viewprofile.php?user=$1 [L]
RewriteRule ^([^/]*)$ /viewtopic.php?topic=$1 [L]

i dont know what the problem is

EDIT the server error log is giving me this error

[Thu Oct 14 20:34:36 2010] [error] 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., 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

谁人与我共长歌 2024-10-04 04:42:58

第二条规则 ^([^/]*)$ 的模式也与不带路径前缀 //viewtopic.php 匹配,即viewtopic.php。这就是为什么你有无限递归。

您可以使用以下条件来排除:

RewriteCond $1 !=viewtopic.php
RewriteRule ^([^/]*)$ /viewtopic.php?topic=$1 [L]

或者使用此条件来排除所有现有文件:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]*)$ /viewtopic.php?topic=$1 [L]

或者在其他规则前面使用此规则来阻止可以映射到由任何以下规则重写的现有文件的每个请求:

RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]

The pattern of your second rule ^([^/]*)$ does also match /viewtopic.php without the path prefix /, i.e. viewtopic.php. That’s why you’re having an infinite recursion.

You can use the following condition to exclude that:

RewriteCond $1 !=viewtopic.php
RewriteRule ^([^/]*)$ /viewtopic.php?topic=$1 [L]

Or use this condition to exclude all existing files:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]*)$ /viewtopic.php?topic=$1 [L]

Or use this rule in front of you other rules to stop every request that can be mapped to an existing file being rewritten by any following rules:

RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文