简体   繁体   English

htaccess重写给我500错误?

[英]htaccess rewrite is giving me 500 error?

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 我有一个我想使其友好的URL,在.htacess上使用重写,但它给了我一个错误(500个内部服务器错误),这是我的原始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: 这是我的整个htaccess代码是这样的:

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., 

The pattern of your second rule ^([^/]*)$ does also match /viewtopic.php without the path prefix / , ie viewtopic.php . 第二个规则^([^/]*)$也匹配/viewtopic.php但没有路径前缀/ ,即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]

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

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