gpt4 book ai didi

regex - htaccess 重写以包含 #!

转载 作者:行者123 更新时间:2023-12-03 07:43:51 25 4
gpt4 key购买 nike

调用所有 .htaccess 专家。我需要你的帮助!

我正在尝试强制重写以包含 #!在网址中。

所以基本上我需要。 http://example.com/biography

将被重写为 http://example.com/#!/biography

如果这会产生任何影响,到目前为止我的重写规则是

  RewriteEngine On  RewriteCond %{HTTPS} !=on  RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]  RewriteRule ^(.*)$ http://%1/$1 [R=301,L]  RewriteCond $1 !^(images|system|files|themes|static|favicon\.ico|robots\.txt|index\.php) [NC]  RewriteRule ^(.*)$ /index.php/$1 [L]

我很擅长这些东西,所以任何帮助将不胜感激。

另外...

我让这个测试在这个 htaccess 测试器中完成我需要它做的事情。 http://htaccess.madewithlove.be/但当我在我的网站上尝试时它不起作用...

RewriteCond %{REQUEST_URI} !^/#!RewriteRule ^(.*)$ /#!/$1 [L]

不知道为什么它不起作用?

谢谢,马克。

最佳答案

让你的 .htaccess 像这样:

Options +FollowSymlinks -MultiViews
RewriteEngine on

RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

RewriteRule ^(biography)/?$ /#!/$1 [R,L,NE,NC]

RewriteCond $1 !^(images|system|files|themes|static|favicon\.ico|robots\.txt|index\.php) [NC]
RewriteRule ^(.*)$ /index.php/$1 [L]

请记住,您不能在 .htaccess 中设置检查 /#! 的条件,因为该部分仅在浏览器中处理,不会发送到 Web 服务器。

关于regex - htaccess 重写以包含 #!,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5879256/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com