URL中的哈希字符(在Apache中访问和重定向) [英] Hash character in URLs (accessing and redirecting in Apache)

查看:119
本文介绍了URL中的哈希字符(在Apache中访问和重定向)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题似乎已经被其他一些人提出了,但我找不到我正在寻找的具体答案,因此,我认为我会提出自己的特殊情况,以防任何人能够提供帮助

It looks as though this question has been asked in part by some others, but I can't find the answer I'm looking for specifically, so I thought I'd pose my particular scenario in case anyone is able to help.

我们有一个旧网站(由第三方外部开发),该网站将被淘汰,并由内部设计的新网站取代.由于众所周知的原因,旧站点的开发人员使用井号字符作为旧站点URL的一部分(www.mysite.com/#/my-content-stuff).为了协助进行转换并提供SEO帮助,我需要为旧网站中效果最好的URL设置301重定向.但是,正如我现在发现的那样,我无法在.htaccess文件中设置简单的重定向,因为我认为它将哈希字符作为注释并忽略了该行的其余部分.我尝试了转义字符,改用%23,通配符匹配,似乎没有任何作用.

We have an old website (developed externally by a third party) that is due to be retired and replaced by a new site designed in house. For reasons best known to themselves, the developers of the old site used the hash character as part of the URL for the old site (www.mysite.com/#/my-content-stuff). To assist with the transition and help with SEO I need to set up 301 redirects for the top performing URLs from the old site. As I'm now discovering however, I'm not able to set up a simple redirect in the .htaccess file as I believe it takes the hash character to be a comment and ignores the remainder of the line. I've tried escape characters, using %23 instead, wildcard matching, nothing seems to work.

作为一种解决方法,我想知道如何简单地创建具有与旧站点相同的路径和URL的虚拟文件,然后简单地在其中创建HTML重定向以将流量吸引到正确的新页面,但是看起来服务器好像是对网址中的哈希字符执行类似的操作,然后忽略之后的任何内容.因此,如果我在新闻服务器上创建一个名为#"的子文件夹,并在其中创建一个名为"test.html"的文件,那么我希望能够直接访问"www.myNEWsite.com/#/test". html",但这只是将我带到网站的默认根文件.

As a workaround, I wondered about simply creating dummy files with the same paths and URLs as the old site had, then simply creating HTML redirects within them to drive traffic to the correct new pages, but it looks as though the server is doing something similar regarding the hash character in the URL, and ignoring anything afterit. So, if I create a sub-folder on my news server called '#' and create a file in there called 'test.html', I expected to be able to just go to 'www.myNEWsite.com/#/test.html', but it just takes me to the default root file of my site.

请任何人阐明我如何解决这个问题?我必须承认,我对Apache并不那么了解,所以我必须学习很多东西.

Please can anyone shed any light on how I might get around this? I must admit I'm not that clued up on Apache so I'm having to learn a lot as I go.

在此先感谢任何人可以提供的任何指针或信息.

Many thanks in advance for any pointers or info anyone can provide.

干杯

丰富

推荐答案

URL中的哈希字符指定了锚点,甚至没有发送到您的Web服务器.重定向在服务器端是不可能的,老开发人员可能使用JavaScript进行了重定向.在不使用哈希的情况下实现后备网址,并使用全局JavaScript脚本检测这些网址并自动重定向.

A hash character in the URL specifies the anchor, and it's not even sent to your webserver. A redirect is impossible on the server side, and the old developer probably did it using JavaScript. Implement fallback URLs without the hash instead, and have a global JavaScript script detect these URLs and redirect automatically.

这篇关于URL中的哈希字符(在Apache中访问和重定向)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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