mod_rewrite规则删除#!来自URL? [英] mod_rewrite rule to remove #! from URL?

查看:77
本文介绍了mod_rewrite规则删除#!来自URL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个带有ajax加载的javascript应用程序,并且万一任何用户访问的URL中都带有hashbang,我想重写该URL并将其删除.我对mod_rewrite不太熟悉,但是我试了一下:

I am building a javascript application with ajax loads, and incase any user visits a URL with a hashbang in it, I want to rewrite the URL and remove it. I am not very familiar with mod_rewrite, but I gave this a shot:

RewriteCond %{REQUEST_URI} ^#! [NC] 
RewriteRule ^#!/(.*)$ http://mysite.com/$1 [R=301]

我什至尝试在两个地方都使用\#\!来转义特殊字符,但是不知何故,我得到了一些奇怪的erractic重定向.
有任何mod_rewrite专家吗?
谢谢!

I even tried escaping the special characters by using \#\! in both the places, but somehow I getting some weird erractic redirects.
Any mod_rewrite experts out there?
Thanks!

推荐答案

URI的片段仅供本地使用,不属于对服务器的请求,因此在服务器端不可用.因此,您无法使用mod_rewrite或任何其他服务器端技术将其删除.

The fragment of a URI is only for local use and is not part of the request to the server and thus not available on the server side. So you can’t remove it with mod_rewrite or any other server side technique.

这篇关于mod_rewrite规则删除#!来自URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆