使用RewriteRule从重定向中删除主题标签 [英] Remove hashtag from redirect with RewriteRule

查看:70
本文介绍了使用RewriteRule从重定向中删除主题标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在通过采用一个变量并将其插入新URL来重定向URL.像这样:

I'm currently redirecting a URL by taking a variable and inserting it into a new URL. Like so:

RewriteCond %{QUERY_STRING} &pid=([0-9]*)$
RewriteRule ^vault/displayimage\.php$ photos/%1/? [R=301,L]

不幸的是,某些链接在旧系统中具有#标签,而这些标签是不需要的,因此我想在没有链接的情况下进行重定向(或剥离它们).前任. -通过上面的重定向,我们采取类似的方法

Unfortunately some links have a hashtag in the old system which aren't needed, so I'd like to redirect without them (or strip them off). Ex. - with the above redirect we take something like

/vault/displayimage.php?album=5&pid=10#top_pictures

重定向到

/photos/10/#top_pictures

我只是想成为

/photos/10/

感谢任何提示!

推荐答案

位置哈希仅存在于浏览器中,并且永远不会发送到服务器.因此,您无法使用重写规则来影响它们.

Location hashes exist only in the browser and are never sent to the server. Thus, you cannot influence them with rewrite rules.

这是人们建议不要使用它们的原因之一.

另请参见 URL片段和302重定向

这篇关于使用RewriteRule从重定向中删除主题标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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