友好 URL 和主播

Friendly URL and Anchors

我正在努力实现文档转到带有友好 URL 的锚点名称。

RewriteRule ^files/page/([a-zA-Z0-9\-]+)?$ myPage.html#

但这行不通。

我尝试将 url 插入页面:myPage.html#myAnchor 并且工作正常。所以问题一定出在htaccess这一行。

我搜索并找到了 this 个旧问题,答案似乎有效,但不幸的是对我来说无效。

HTACCESS 文件(使用 [L] 标志更新):

AddType text/x-component .htc

RewriteEngine on
RewriteBase /

RewriteRule ^ahorro/?$ ahorro-para-mi-futuro.html [L]
RewriteRule ^ahorro/como-es-nuestro-ahorro/([a-zA-Z0-9\-]+)?/?$ como-es-nuestro-ahorro.html# [L]
RewriteRule ^ahorro/preparado-para-tu-jubilacion/?$ hasta-que-punto-estas-preparado-para-tu-jubilacion.html [L]
RewriteRule ^ahorro/ventajas-fiscales/?$ ventajas-fiscales.html [L]
RewriteRule ^ahorro/para-mi-futuro/([a-zA-Z0-9\-]+)?/?$ por-que-deberia-ahorrar-para-mi-futuro.html# [NE,NC,L]

RewriteRule ^preparar-jubilacion/?$ preparo-mi-jubilacion.html [L]
RewriteRule ^preparar-jubilacion/calcula-tu-patrimonio/?$ calcula-tu-patrimonio.html [L]
RewriteRule ^preparar-jubilacion/calculadora-gastos/?$ calculadora-de-gastos.html [L]
RewriteRule ^preparar-jubilacion/disponibilidad-de-ahorros/?$ como-podre-disponer-de-mis-ahorros.html [L]
RewriteRule ^preparar-jubilacion/4-pasos-para-mi-jubilacion/?$ 4-pasos-para-planificar-tu-jubilacion.html [L]

RewriteRule ^vivir-jubilacion/?$ vivo-mi-jubilacion.html [L]
RewriteRule ^vivir-jubilacion/prioridades/?$ que-necesito-y-cuales-son-mis-prioridades.html [L]
RewriteRule ^vivir-jubilacion/disponer-de-mis-ahorros/?$ como-podre-disponer-de-mis-ahorros.html [L]
RewriteRule ^vivir-jubilacion/4-pasos-para-mi-jubilacion/?$ 4-pasos-para-planificar-tu-jubilacion.html [L]

RewriteRule ^encuentros/?$ encuentros-futuros.html [L]

RewriteRule ^calculadoras-y-simuladores/calculadora-ahorro/?$ calculadora-de-ahorro.html [L]
RewriteRule ^calculadoras-y-simuladores/calculadora-gastos/?$ calculadora-de-gastos.html [L]
RewriteRule ^calculadoras-y-simuladores/calcula-tu-patrimonio/?$ calcula-tu-patrimonio.html [L]

RewriteRule ^politica-cookies/?$ politica_cookies.html [L]

尝试使用 NE(无转义)标志

RewriteRule ^files/page/([a-zA-Z0-9\-]+)?$ myPage.html# [NE,NC,L]

来源:

Apache 重写标志:https://httpd.apache.org/docs/2.4/rewrite/flags.html

我想我知道发生了什么,史诗般的脸掌

# 它正在评论它之后的所有内容,因此,它不起作用是合乎逻辑的。解决方法,在REGEX里面加#.

RewriteRule ^ahorro/para-mi-futuro/?(\#[a-zA-Z0-9\-]+)?/?$ por-que-deberia-ahorrar-para-mi-futuro.html [NE,NC,L]