包括hashtag Apache中的.htaccess [英] hashtag in apache .htaccess

查看:202
本文介绍了包括hashtag Apache中的.htaccess的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过下面的.htaccess

By using the following .htaccess

RewriteEngine On
RewriteRule ^([0-9]+)/([0-9]+)$ /api/web/index.html#$1/$2 [R=301,NC,L]

当用户键入以下URL在他们的浏览器。

When user types the following URL at their browser.

http://localhost:8080/1/2

我期待,Apache会执行内部重定向,并改变在浏览器中显示的URL太(通过R = 301)。

I'm expecting, Apache will perform internal redirection, and change the displayed URL at browser too (through R=301).

http://localhost:8080/api/web/index.html#1/2

更改显示的URL在浏览器中是很重要的。这是为了确保 index.html的的JavaScript可以正确解析URL。

Changing the displayed URL at browser is important. This is to ensure index.html's JavaScript can parse the url correctly.

不过,我真正得到的是

http://localhost:8082/api/web/index.html%231/2

我会得到Apache的错误。

I will get Apache error.

Apache的错误想法,我想取 2 位于目录 API /网络/ index.html的231%/

Apache false thought that, I wish to fetch a file named 2 located in directory api/web/index.html%231/

有什么我可以通过修改的.htaccess 只?

Is there anything I can solve this through modifying .htaccess only?

推荐答案

越来越EN codeD为%23 。尝试使用 NE 标记在您的规则:

The # is getting encoded as %23. Try using the NE flag in your rule:

RewriteRule ^([0-9]+)/([0-9]+)$ /api/web/index.html#$1/$2 [R=301,NC,L,NE]

NE 标记告诉mod_rewrite的不连接code中的URI。

the NE flag tells mod_rewrite not to encode the URI.

这篇关于包括hashtag Apache中的.htaccess的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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