我想将着陆页网址从www.example.com/更改为www.example.com/index/id
我尝试过
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /example/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
Redirect 301 / http://example.com/index/id
RewriteRule ^index/([^/]*)$ ?i=page.index&lang=$1 [L]
</IfModule>
但不行。
请帮助我解决此问题。谢谢你。
答案 0 :(得分:0)
要将URL从index.php
重写为/index/id
,您需要执行以下两个步骤:
htdocs
文件夹中),名称为.htaccess
.htaccess
文件中。RewriteEngine On
RewriteRule ^index/id index.php [L]
但是其中存在一个问题,该代码仅允许您将所有流量从index.php
重定向到新名称时,使用其他名称访问index.php
,我建议您不要进行更改.htaccess
文件中的文件只需检测URL
文件中的当前index.php
并根据需要将其重定向。
示例
<?
$actual_link = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
if(parse_url($actual_link, PHP_URL_PATH) != "/index/id"){
header('Location: /index/id');
}
else{
// do nothing
}
?>
希望这对您有所帮助,谢谢?