gpt4 book ai didi

php - 检查网站是否被 .htaccess 重定向

转载 作者:行者123 更新时间:2023-12-04 06:02:44 26 4
gpt4 key购买 nike

我在 .htaccess 文件中有以下规则:

RewriteRule orders\.html orders.php [L,NC]

如何在 orders.php 中检查用户是否输入了 orders.html 或 orders.php 作为请求 URL?

如果他/她在地址栏中有 orders.php,我想将用户重定向到 orders.html。

最佳答案

I want to redirect user to orders.html if he/she has orders.php in the address bar



如果您正在寻找 .htaccess 解决方案,请尝试以下代码
RewriteEngine on
RewriteBase /

#if the user requested orders.php
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /orders\.php [NC]
#301 redirect them to orders.html
RewriteRule . orders.html [L,R=301]

#existing rule to rewrite .html to .php
RewriteRule ^orders\.html$ orders.php [L,NC]

关于php - 检查网站是否被 .htaccess 重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8762948/

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