簡體   English   中英

RedirectMatch和隱藏URL

[英]RedirectMatch and hide URL

假設有一個名為me.com的網頁,我希望/project/index.php的文件成為主根文件。

/project/index.php看起來像這樣:

<?php
header('Location: /project/site-one.html');
exit;
?>

.htaccess看起來像這樣:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RedirectMatch ^/$ /project/index.php [L]

    # more rules follow

現在,如果我訪問me.com我會得到me.com/project/site-one.html

我想要的是,始終只要有/project/site-one.html/project/index.php即可在adressbar中將me.com顯示為URL。

這怎么可能? 我已經嘗試過RewriteRule並僅傳遞[L]標志,但是我沒有想要的東西。

您可以在根.htaccess(高於project的級別)中像這樣使用.htaccess:

RewriteEngine On
RewriteRule ^/?$ /project/site-one.html [L]

您應該從index.php刪除header(...)函數調用

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM