我有一个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
发布评论