开发者

mod_rewrite rule to remove #! from URL?

开发者 https://www.devze.com 2023-02-16 16:00 出处:网络
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 i开发者_高级运维t. I am not very familiar with mod_

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 i开发者_高级运维t. 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]

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!


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消