.htaccess的URLRewrite到其他地图

编程入门 行业动态 更新时间:2024-10-24 06:27:10
本文介绍了.htaccess的URLRewrite到其他地图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

当我去{URL} / klanten /家庭/或{URL} / klanten /注销/ 500内部服务器错误来了。

When i go to {url}/klanten/home/ or {url}/klanten/logout/ a 500 Internal Server Error come.

我的htaccess的:

My htaccess:

RewriteEngine on RewriteRule ^klanten/([^/]+)/?$ klanten/$1.php [L,QSA,NC] RewriteRule ^error/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$ error.php?type=$1&error=$2&file=$3&from=$4 [L,QSA,NC] RewriteRule ^email/([^/]+)/?$ email.php?id=$1 [L,QSA,NC] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule ^(.*)$ $1.php [L]

地图klanten'存在,并且该文件home.php和logout.php存在了。

The map 'klanten' exists and the file home.php and logout.php exists too.

谢谢!

推荐答案

这条规则是错误的,它会导致不确定的重定向:

This rule is wrong, it leads to an indefinite redirect:

RewriteRule ^klanten/([^/]+)/?$ klanten/$1.php [L,QSA,NC]

/ klanten /退出/ 将导致 /klanten/logout.php 这反过来将再次被改写又一遍。

/klanten/logout/ will lead to /klanten/logout.php which in turn will be rewritten again and again.

您可以添加点到字符类,以避免让没有点只有网址被重写:

You could add the dot to the character class to avoid that so that only urls without a dot get rewritten:

RewriteRule ^klanten/([^/\.]+)/?$ klanten/$1.php [L,QSA,NC]

或你只需要添加现有的文件和目录不会被重写的条件(显然是更好的解决办法...):

or you just add the conditions that existing files and directories do not get rewritten (obviously the better solution...):

RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^klanten/([^/]+)/?$ klanten/$1.php [L,QSA,NC]

更多推荐

.htaccess的URLRewrite到其他地图

本文发布于:2023-11-01 02:25:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1547984.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:地图   htaccess   URLRewrite

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!