[英]Removing a string from url in php
How to remove a specific string from URL in .htaccess file. 如何从.htaccess文件中的URL中删除特定的字符串。
For example my root URL is www.example.com
. 例如,我的根URL是
www.example.com
。 If someone puts www.example.com/#
, it should redirect to root URL. 如果有人输入
www.example.com/#
,则应重定向到根URL。
I have tried with 我尝试过
RewriteEngine on
RewriteBase /
RewriteRule ^#/(.*) /$1 [R=302,L]
The hash in the URL isn`t sent to the server when requesting a page, so you can't use redirect rules like that. 请求页面时,URL中的哈希不会发送到服务器,因此您不能使用这样的重定向规则。 It's client-side only.
仅在客户端。
You can change the url only with javascript: 您只能使用javascript更改网址:
if (location.href.indexOf("#") > -1) {
location.assign(location.href.replace(/\/?#/, ""));
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.