Apache .htaccess 规则冲突
我正在开发一个网络应用程序,人们可以在其中创建个人资料。他们的个人资料存储在:app/user/UserName。我希望 URL 是这样的:app/UserName 但不能,因为我已经设置了 url:app/CategoryName/StoryName,其中有很多类别,如技术、时尚等。这是我的 htaccess 内容:
Options +FollowSymLinks
RewriteEngine on
ErrorDocument 404 /ef12/error/404.html
RewriteRule user/(.*)/ u.php?name=$1
RewriteRule user/(.*) u.php?name=$1
RewriteRule (.*)/(.*)/ scoop.php?cat=$1&title=$2
RewriteRule (.*)/(.*) scoop.php?cat=$1&title=$2
RewriteRule (.*)/ scoop.php?cat=$1
RewriteRule (.*) scoop.php?cat=$1
我想要用户的个人资料显示为:
app/AbhishekBiswal
和故事显示为:
app/technology/steve-jobs
我知道这是可能的:示例 > Twitter:twitter.com/Abhishek_Biswal 和 twitter.com/about,前者是个人资料,后者是关于 Twitter 的页面。
是的,我还有登录和注册等目录( http://app/Login ),这也与规则,也就是说,当我尝试访问 Login 目录时,服务器假定 Login 作为用户名(当我将配置文件 url 设置为 http 时: //应用程序/用户名中htaccess )并显示“无配置文件”错误。
谢谢。
I am developing a web app where people can create profiles. Their Profile is stored at: app/user/UserName. I want the URL to be like this: app/UserName but can't because I have already set the the url : app/CategoryName/StoryName where there are lots of Categories like Technology, Fashion, etc. Here's my htaccess content:
Options +FollowSymLinks
RewriteEngine on
ErrorDocument 404 /ef12/error/404.html
RewriteRule user/(.*)/ u.php?name=$1
RewriteRule user/(.*) u.php?name=$1
RewriteRule (.*)/(.*)/ scoop.php?cat=$1&title=$2
RewriteRule (.*)/(.*) scoop.php?cat=$1&title=$2
RewriteRule (.*)/ scoop.php?cat=$1
RewriteRule (.*) scoop.php?cat=$1
I want the User's Profile To Appear Like:
app/AbhishekBiswal
and stories to appear like:
app/technology/steve-jobs
I know it's possible: example > Twitter: twitter.com/Abhishek_Biswal and twitter.com/about where the former is a profile and the latter is a page about Twitter.
And Yes, I have also got Directories like Login and SignUp ( http://app/Login ), which also Conflicts with the Rules, that is, when I try to access Login directory, the server assumes Login as the UserName ( when I have set the profile url as http://app/UserName in htaccess ) and a "No Profile" Error is shown.
Thank You.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在规则之前添加这些行。如果存在与 URL 匹配的文件或目录,它们会阻止规则生效:
Add these lines before the rules. They prevent the rule from taking effect if a file or directory exist that match the URL: