插入一个哈希与Apache的mod

编程入门 行业动态 更新时间:2024-10-23 15:33:09
本文介绍了插入一个哈希与Apache的mod_rewrite或PHP目录名前?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个URL,它是这样的:

I have a URL that is like the following:

www.example/client/project/subdirectory/value/

我想就像一个简单的方法能够改变/重定向的URL,如下:

I would like like a simple way to be able to change/redirect the URL to the following:

www.example/client/project/#/subdirectory/value/

在重定向完成,哈希需要通过JavaScript访问。我没事了完全刷新/重定向,只是我写这一次,不必再改变它理想的。

Once the redirect is complete, the hash needs to be accessible via JavaScript. I'm okay with a full refresh/redirect, just ideally that I write this once and don't have to change it again.

在换句话说,当网站开始运行时,网址将被不同地构造,以便:

In other words, when the site goes live, the URLs will be structured differently, so that:

www.example/subdirectory/value/

将变为:

www.example/#/subdirectory/value/

编辑:

我一直在使用这种尝试:     重写规则^资料/?$#/型材/ [NC,L]

I have tried using this: RewriteRule ^profile/?$ #/profile/ [ NC,L]

这似乎并没有做任何事情。

Which doesn't seem to do anything

也试过这样:    重写规则^资料/?$ /#/型材/ [NC,L]

Also tried this: RewriteRule ^profile/?$ /#/profile/ [NC,L]

这需要我的根目录

也试过这样:    重写规则^资料/?$#/型材/ [R,NC,L]

Also tried this: RewriteRule ^profile/?$ #/profile/ [R,NC,L]

这增加了整个根路径到服务器,随后/%23 /信息/

Which adds the whole root path to the server, followed by /%23/profile/

推荐答案

如果您有类似下面的网址:

If you have a URL like the following:

localhost/tests/redir/subdirectory/value/

和你想要得到它重定向到:

And you want to get it redirected to:

localhost/tests/redir/#/subdirectory/value/

将的.htaccess 文件到的目录测试/ REDIR 通过以下内容:

Place a .htaccess file into the directory of tests/redir with the following:

RewriteEngine On RewriteBase /tests/redir RewriteRule ^(.*/)$ #/$1 [R,L,NE]

,你会得到想要的重定向。在研究标记与的RewriteBase 指令一起玩。另外, NE 标记是必要的,这样你可以把#字面上到重定向URI。

And you will get the wanted redirect. The R flag plays together with the RewriteBase directive. Also the NE flag is necessary so that you can put # literally into the redirect URI.

更多推荐

插入一个哈希与Apache的mod

本文发布于:2023-11-01 11:54:57,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1549267.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Apache   mod

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!