[英]htaccess redirect dynamic url to one with hashbang
I have http://domain.com/frame/1234sdfs
but I want to change it to http://domain.com/#/frame/1234sdfs
我有http://domain.com/frame/1234sdfs
但我想将其更改为http://domain.com/#/frame/1234sdfs
I'm using trial and error at the moment and getting nowhere with the following in my .htaccess 我目前正在使用试错法,而我的.htaccess中的以下内容一无所获
RedirectMatch 301 ^/frame/([^/]*)$ /#/frame/$1
Could someone place me in the right direction? 有人可以把我放在正确的方向吗? I have been using http://htaccess.madewithlove.be/ to try get the output URL as expected but can't figure it out. 我一直在使用http://htaccess.madewithlove.be/尝试获得预期的输出URL,但无法弄清楚。
You should use mod_rewrite so that you can use the NE
flag. 您应该使用mod_rewrite,以便可以使用NE
标志。 It's probably being converted to %23
using mod_alias
. 可能已使用mod_alias
其转换为%23
。 You need to send it literally with this code here. 您需要在此处使用此代码按字面意义发送它。
RewriteEngine On
RewriteRule ^frame/([^/]+)/?$ /#/frame/$1 [NE,L,R=301]
Omitting the [NE] will result in the # being converted to its hexcode equivalent, %23, which will then result in a 404 Not Found error condition. 省略[NE]将导致#转换为其等效的十六进制代码%23,然后将导致404 Not Found错误情况。
https://httpd.apache.org/docs/2.4/rewrite/flags.html#flag_ne https://httpd.apache.org/docs/2.4/rewrite/flags.html#flag_ne
Note: Makes sure .htaccess is allowed and mod_rewrite is enabled. 注意: 确保允许.htaccess并启用mod_rewrite。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.