htaccess修改URL
我有网址:
http://example.com/at
and want to get:
http://example.com/at/index.php?at=
http://example.com/at/
and want to get:
http://example.com/at/index.php?at=
http://example.com/at/1asSde
and want to get:
http://example.com/at/index.php?at=1asSde
文件夹“at”中的.htaccess
此外,我正在修改位于我一直在尝试的
RewriteEngine On
RewriteRule (.*)$ index.php?at=$1 [QSA,L]
:但稍后在运行该网站的脚本时出现错误。
为了获得正确的结果,我可以尝试什么?
谢谢。
I have the urls:
http://example.com/at
and want to get:
http://example.com/at/index.php?at=
http://example.com/at/
and want to get:
http://example.com/at/index.php?at=
http://example.com/at/1asSde
and want to get:
http://example.com/at/index.php?at=1asSde
Also I am modifying the .htaccess located at the folder 'at'
I've been trying:
RewriteEngine On
RewriteRule (.*)$ index.php?at=$1 [QSA,L]
but am getting errors later when running the script of the site.
What can I try instead in order to get the correct results?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
尝试以下操作
只要
at/index.php
是物理位置,您就不需要at
规则。我鼓励您为at
创建更好的匹配。例如,如果(.*)
只能是字母数字,则将其更改为(\w+)
。Try the following
You don't need a rule for
at
so long asat/index.php
is a physical location. I would encourage you to create a better match forat
. For example change(.*)
to(\w+)
if it can only be alphanumeric.RewriteRule ^at/(.*)$ /at/index.php?at=$1 [QSA,L]
RewriteRule ^at/(.*)$ /at/index.php?at=$1 [QSA,L]
在重写 URL 之前,您需要确保您尝试获取的资源不存在:
You will want to make sure that the resource you're trying to get doesn't exist before rewriting the URL: