为什么这样的.htaccess重写规则,其中包括一个'#'失败? [英] Why does this .htaccess RewriteRule that includes a '#' fail?

查看:94
本文介绍了为什么这样的.htaccess重写规则,其中包括一个'#'失败?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目标:匹配URL和重写它来查询字符串

Goal: Match URL and rewrite it to a query string.

问题:看起来像#(一切后)在替换字符串中被忽略

Problem: Looks like the "#" (and everything after it) in the replacement string is being ignored.

下面是我有:

RewriteEngine On
RewriteRule ^([^\.]+)$ $1.html [NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+) web2.html#list?d=$1&n=$2 [L,NE]

这到达 web2.html 但是URL参数( D =安培; N = )永远不会应用

This gets to web2.html but the url parameters (d= & n=) are never applied.

我们的目标是让一个网址,如: somewehere.com/55c26838e4b087b032b432c4/1 / 来触发这样的查询: somewehere.com/ WEB2#名单D = 54668494e4b09ffed41ff167和放大器; N = 1

The goal is to allow a url like: somewehere.com/55c26838e4b087b032b432c4/1/ to trigger a query like this: somewehere.com/web2#list?d=54668494e4b09ffed41ff167&n=1

推荐答案

哈希标签用于仅客户端。尝试重定向你的要求,以研究标志指定的。

Hash-tags are used on client-side only. Try to redirect your request, with R flag specified.

RewriteRule ^([^/]+)/([^/]+) web2.html#list?d=$1&n=$2 [R=301,NE,L]

如果不行叉你,看看HTML5的历史API ​​。我觉得 pushState 方法可以帮助你。

If that doesn't work fork for you, take a look at HTML5 History API. I think pushState method can help you.

这篇关于为什么这样的.htaccess重写规则,其中包括一个'#'失败?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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