2015-02-06 46 views
0

我想把我的網站在線。到目前爲止,我的index.php文件是在這個目錄下:網站變更索引目錄

www.website.com/directory/subdirectory/index.php

我的問題:參觀者應看到的index.php時他訪問www.website.com

如何鏈接/路由訪問者到子目錄/ index.php?否則,我將不得不改變我的網站內的所有鏈接。 謝謝!

+3

簡單的問題..如果你知道你想從根服務它,你爲什麼要讓你的網站開始2層? – 2015-02-06 21:18:11

+0

你只需要訪問這個頁面(整個網站是由用戶從這個頁面調用的),還是你有其他頁面需要用戶訪問這個'directory /子目錄'? – tleb 2015-02-07 07:53:00

回答

0

僅此頁查看:

創建.htaccess文件在您的網站,並在它的根,把:

RewriteEngine on 
RewriteRule ^(.*) directory/subdirectory/index.php 

這意味着,發送到服務器的任何請求都將返回什麼會如果我們撥打directory/subdirectory/index.php,我們會退回。

如果您想要獲取GET請求,您需要對其進行調整。

重定向:

你的網站的根目錄下創建一個文件index.php,並在其中,把:

<?php 
header("Location: directory/subdirectory/index.php"); 

這將用戶發送到directory/subdirectory/index.php

+0

重定向很完美!非常感謝! – user2929899 2015-02-07 14:09:35

0

添加到這個你的.htaccess

#Alternate default index page 
DirectoryIndex index.php 

因爲它是現在,在默認情況下,當有人訪問你的website.com,index.html的是目前默認。

您可以將index.php更改爲任何文件。