我已經想出了這一個,使用htaccess和PHP相結合。我會在這裏留下這個情況,其他人遇到這種情況,我無法在互聯網上找到任何幫助
首先,您需要將所有正常的網站文件移動到一個子目錄中,已經被稱爲「正常」爲了這個目的,所以你的文件現在看起來是這樣:
>public_html
>normal
>index.php
>other
>files
>elastik
>all
>elastic
>files
現在創建一個.htaccess文件重定向中的public_html一切的index.php文件看起來像這樣:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]
然後在public_htm中的index.php文件1目錄應該是這個樣子:
<?php
if(isset($_SERVER['HTTP_REFERER'])){
if(strpos($_SERVER['HTTP_REFERER'], "localhost/elastik")){
header("Location: /elastik".$_SERVER['REQUEST_URI']);
}
else{
$uri = $_SERVER['REQUEST_URI'];
header("Location: /normal".$uri);
}
}
else{
header("Location: /normal".$uri);
}
?>
我不得不搬到我的PHP包括在關係Cyclobutyl提及的文檔根,回到public_html目錄,但我做了後,一切運行順利