【发布时间】:2020-12-02 10:35:20
【问题描述】:
最奇怪的事情。两个重写规则都在我们的测试服务器上运行,但第二个locations 不适用于生产,并且出于某种原因在locations/ 的末尾添加了一个/。两台服务器上的配置相同。
我正在尝试在不重命名文件的情况下简化 URL。这样如果用户输入site.php/locations,它将加载重定向页面的内容,但保留简化的 URL
关于为什么locations 重定向不起作用的任何想法?
RewriteEngine on
RewriteBase /
// The next two are statements are just for context. They preceded the faq and locations forward
RewriteCond %{REQUEST_URI} ^/index.php$
RewriteRule (.*) / [R=301,L]
// The two rewrites that I want
RewriteRule ^faq$ /faq-mailbox-account.php [NC,L]
RewriteRule ^locations$ /choose-digital-mailbox-location.php [NC,L]
【问题讨论】:
-
这里缺少一些东西...
site.php/locations将显然永远不会与^locations$匹配。但同样适用于“常见问题”规则。因此,请花时间修改您的问题。解释你的真实设置。 -
忘记包含 RewriteBase。所以重写应该匹配后面的文本:
site.php/ -
不会改变任何事情。模式无法匹配。
-
请确保您没有查看早期尝试的缓存结果。在两种环境中。
-
我修改了我的问题。我会要求我的经理明天检查缓存,因为他处理服务器的东西。另请注意,它仅被推送到 Prod 一次。并在测试服务器上运行了几次。并且
faq重定向在所有实例上都可以正常工作,只是locations有问题
标签: php apache .htaccess mod-rewrite url-rewriting