【问题标题】:How to redirect a site subfolder to a page如何将站点子文件夹重定向到页面
【发布时间】:2017-09-21 06:27:49
【问题描述】:

我有一个多语言网站 我要:

exemple.be/nl/

重定向到

exemple.be/nl/start_nl.php

exemple.be/fr/

重定向到

exemple.be/fr/start_fr.php

我可以使用 .htaccess 吗?

我试过了,没用:

301 /nl/ https://exemple.be/nl/start_nl.php

【问题讨论】:

  • 我认为您的网址中有一种语言网站视图?如果是,您可以通过锚标记或使用 url 重定向功能使用 javascrip 或 php 传递

标签: php html .htaccess server


【解决方案1】:

在 php 中有一个名为 setlocale 的函数,可用于制作它,以便它通过 header("Location: start_nl.php"); 转到特定站点;

http://php.net/manual/en/function.setlocale.php

但除此之外,您可以这样做,以便 index.php 使用 header("Location: start_fr.php"); 转到特定站点。 只需放在顶部,在 php 的开始标记下:

<?php
header("Location: start_fr.php");
?>

也可以用html来完成。

<meta http-equiv="refresh" content="2; URL=start_fr.php">

【讨论】:

    【解决方案2】:

    我在另一个网站上找到了答案 在 .htaccess 文件中,我写道:

    RewriteEngine On
    RewriteRule ^nl/?$ https://exemple.be/nl/nl-start.php
    RewriteEngine On
    RewriteRule ^fr/?$ https://exemple.be/fr/fr-start.php
    

    【讨论】:

      猜你喜欢
      • 2015-11-22
      • 2023-03-27
      • 1970-01-01
      • 1970-01-01
      • 2023-04-08
      • 2016-05-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多