2011-02-22 175 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]