简体   繁体   English

当文件名与目录名匹配时,RewriteRule导致内部错误

[英]RewriteRule causes Internal Error when filename matches directory name

I've made it so that /user/username successfully directs the user to /userui.php?username=username . 我这样做是为了使/user/username成功将用户定向到/userui.php?username=username However, if I change the name of userui.php to user.php , I get internal errors since the name of the fake directory matches the name of the real file. 但是,如果我将userui.php的名称更改user.php则会出现内部错误,因为假目录的名称与真实文件的名称匹配。

What changes can be made so I can successfully name my file user.php and still serve to the /user/ directory? 可以进行哪些更改,以便我可以成功命名文件user.php并仍投放到/ user /目录?

Working fine: 工作正常:

RewriteRule ^user/([^/]+)$ userui.php?username=$1 [L,QSA]

Internal Server Error: 内部服务器错误:

RewriteRule ^user/([^/]+)$ user.php?username=$1 [L,QSA]

Try turning off MultiViews by placing this line: 尝试通过放置以下行来关闭MultiViews

Options -MultiViews

on top of your .htaccess. 在您的.htaccess之上。 Option MultiViews is used by Apache's content negotiation module that runs before mod_rewrite and makes Apache server match extensions of files. Apache's content negotiation module使用Option MultiViews ,该Apache's content negotiation module mod_rewrite 之前运行,并使Apache服务器匹配文件扩展名。 So /file can be in URL but it will serve /file.php . 因此/file可以位于URL中,但它将提供/file.php

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

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