我正在努力实现文档转到带有友好 URL 的 anchor 名称。
RewriteRule ^files/page/([a-zA-Z0-9\-]+)?$ myPage.html#$1
但这行不通。
我尝试将 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#$1 [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#$1 [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#$1 [NE,NC,L]
来源:
Apache 重写标志:https://httpd.apache.org/docs/2.4/rewrite/flags.html
关于html - 友好的 URL 和 anchor ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33735367/