【问题标题】:Htacces/Php - Too many redirectsHtaccess/Php - 重定向太多
【发布时间】:2017-04-16 01:52:41
【问题描述】:

我正在尝试在我正在本地处理的网站上创建干净的 URL。

我正在使用 WampServer。

这是我的.htaccess 内容

RewriteEngine on
RewriteRule ^search/([0-9a-zA-Z]+) search.php?semt=$1 [NC,L]

这是我在search.php 文件中所做的事情。

<?php
if(!isset($_GET["semt"]) || empty($_GET["semt"])){
    header("Location: index.php");}
else{
    $region = $_GET["semt"];
    include('database/config.php');
    include('includes/header.php');}
?>

当我打字时,

localhost/project/search.php?semt=xxx 它非常有效。

当我打字时,

本地主机/项目/搜索/xxx

它不工作。浏览器出现此错误。

error screen capture

此页面无法正常工作

localhost 将您重定向了太多次。 尝试清除您的 cookie。 ERR_TOO_MANY_REDIRECTS

链接的最终版本是这样的。

localhost/project/search/index.php

我该如何解决这个问题?

【问题讨论】:

  • xxx 是您实际使用的,还是代表其他东西?
  • 为例。我尝试使用RewriteRule ^esc/search/([0-9a-zA-Z]+) localhost/esc/search.php?semt=$1 [NC,L],但没有成功。

标签: php apache .htaccess redirect


【解决方案1】:

您应该从您的最终网址中了解为什么会发生这种情况。将重定向更改为 /index.php。

【讨论】:

    猜你喜欢
    • 2019-09-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-15
    相关资源
    最近更新 更多