2011-02-22 180 views
1

我的問題很簡單。我有我的主網頁(www.domain.com/index.php)網站重定向

  1. 有沒有辦法將用戶重定向到的index.php時,他只種www.domain.com?

  2. 同時從網址中刪除index.php?

我檢查了一下.htaccess,但沒有一個技巧似乎能完成這項工作。

謝謝!

編輯

這裏是我的.htaccess:

# To set your custom php.ini, add the following line to this file: 
# suphp_configpath /home/yourusername/path/to/php.ini 

DirectoryIndex index.php 

Options +FollowSymLinks 
RewriteEngine On 
RewriteCond %{HTTP_HOST} !^www\. 
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] 

<Files .htaccess> 
order allow,deny 
deny from all 
</Files> 

Options All -Indexes 

正如你所看到的,我把DirectoryIndex的index.php文件在裏面,但不會改變它:(

+0

1&2種衝突,不要t嘿? 「去那裏,但不要表明你在那裏」。除了在Apache中使用index.php作爲默認文檔(使用DirectoryIndex作爲下面的Hamish回答),您無法真正控制用戶在地址欄中看到的內容。 – 2011-02-22 22:16:19

+0

@Marc,當然你可以 - 這就是HTTP重定向的目的。 'index.php'→'/'external,'/'→'index.php'內部,非常有意義:) – aaz 2011-02-22 22:25:33

+0

hehe我的意思是:用戶類型www.domain.com,他被重定向到www.domain.com/ index.php,但它保持www.domain.com。基本上,index.php成爲默認頁面。 – Elggetto 2011-02-22 22:27:25

回答

3

簡而言之

DirectoryIndex index.php 

在你的.htaccess

當用戶鍵入www.domain.com它會採取的index.php默認索引頁,並榮獲」 t在地址中顯示

+0

hummm似乎不起作用。我在我的問題中寫了我的.htaccess。 – Elggetto 2011-02-22 22:29:54

+0

@Elggetto:不工作不是一個真正的答案。當你繼續** www.domain.com **時,它會做什麼? – Shikiryu 2011-02-22 22:38:28

+0

對不起。它直接到** www.domain.com/index.html **(我有一個臨時index.html只用於測試) – Elggetto 2011-02-22 22:42:32

0

在域控制面板提到開始/索引頁面爲index.php 通常index.html/htm是默認頁面 您可以在網站證書下找到這些選項

0
Redirect/http:/your.domain.php/index.php 
+1

這將顯示'HTTP:在地址/ your.domain.php/index.php',和OP希望'http:/ your.domain.php /' – Shikiryu 2011-02-22 22:18:06

+0

我的不好。必須更好地閱讀問題! – StephenC 2011-02-22 22:52:58

0
RewriteEngine On 
RewriteBase/ # URL path corresponding to this directory 
RewriteRule (^|.*/)index\.php$ $1 [R]