网站重定向
问题描述:
我的问题很简单。我有我的主网页(www.domain.com/index.php)网站重定向
有没有办法将用户重定向到的index.php时,他只种www.domain.com?
同时从网址中删除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文件在里面,但不会改变它:(
答
简而言之
DirectoryIndex index.php
在你的.htaccess
当用户键入www.domain.com它会采取的index.php默认索引页,并荣获” t在地址中显示
答
在域控制面板提到开始/索引页面为index.php 通常index.html/htm是默认页面 您可以在网站证书下找到这些选项
答
RewriteEngine On
RewriteBase/ # URL path corresponding to this directory
RewriteRule (^|.*/)index\.php$ $1 [R]
1&2种冲突,不要t嘿? “去那里,但不要表明你在那里”。除了在Apache中使用index.php作为默认文档(使用DirectoryIndex作为下面的Hamish回答),您无法真正控制用户在地址栏中看到的内容。 – 2011-02-22 22:16:19
@Marc,当然你可以 - 这就是HTTP重定向的目的。 'index.php'→'/'external,'/'→'index.php'内部,非常有意义:) – aaz 2011-02-22 22:25:33
hehe我的意思是:用户类型www.domain.com,他被重定向到www.domain.com/ index.php,但它保持www.domain.com。基本上,index.php成为默认页面。 – Elggetto 2011-02-22 22:27:25