.htaccess 将规则从 http://example.com/~something/blabla 重写为 http://example.com/blablabla
.htaccess 重写规则的小问题.. 我想像这样重定向http请求:
http://example.com/~something /blabla/blablabla?blabla=blabla
作为这样的请求:
http:// example.com/blabla/blablabla?blabla=blabla
只需删除 ~something (可以是其他任何东西,但开头带有 ~ ......)
我已经尝试过这段代码,但根本不起作用......:
RewriteEngine on
RewriteRule ~something/(.*) $1 [P,L]
Little question with .htaccess rewrite rule..
I want to redirect http request like that:
http://example.com/~something/blabla/blablabla?blabla=blabla
as an request like that:
http://example.com/blabla/blablabla?blabla=blabla
Simply remove the ~something (with can be anything else but with an ~ at beginning...)
I have tried this code but not working at all...:
RewriteEngine on
RewriteRule ~something/(.*) $1 [P,L]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
沿着这些路线的东西应该可以工作(这假设使用 .htaccess 文件,IIRC,如果您在 Apache 配置文件中执行此操作,则需要在 RewriteRule 指令中添加前导斜杠):
无论哪种方式,RewriteLog 和RewriteLogLevel 指令(请参阅 http://httpd.apache.org/docs/current/mod /mod_rewrite.html)是你在这里的朋友。
Something along these lines should work (this assumes use of a .htaccess file, IIRC you'll need to add a leading slash to the RewriteRule directive if you're doing this in your Apache config file instead):
Either way, the RewriteLog and RewriteLogLevel directives (see http://httpd.apache.org/docs/current/mod/mod_rewrite.html) are your friends here.