Php 网站重定向
我的问题很简单。我有我的主页(www.domain.com/index.php)Php 网站重定向,php,.htaccess,redirect,Php,.htaccess,Redirect,我的问题很简单。我有我的主页(www.domain.com/index.php) 当用户只键入www.domain.com时,有没有办法将其重定向到/index.php 当他在url上时,还要从url中删除index.php 我检查了一下.htaccess,但没有一个技巧能起到作用 谢谢大家! 编辑 这是我的.htaccess: # To set your custom php.ini, add the following line to this file: # suphp_configpat
# 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
#要设置自定义php.ini,请在此文件中添加以下行:
#suphp_configpath/home/yourusername/path/to/php.ini
DirectoryIndex.php
选项+FollowSymLinks
重新启动发动机
重写cond%{HTTP_HOST}^www\。
重写规则^(.*)$http://www.%{HTTP_HOST}/$1[R=301,L]
命令允许,拒绝
全盘否定
选项所有-索引
如您所见,我将DirectoryIndex.php放入其中,但没有对其进行更改:(在域控制面板中,将Start/index页面称为index.php。 通常index.html/htm是默认页面。 您可以在站点项目下找到这些选项。简单地说
Redirect / http:/your.domain.php/index.php
DirectoryIndex index.php
在您的.htaccess中
当用户键入www.domain.com时,它将以index.php作为默认索引页,并且不会显示在地址中,不是吗?“转到那里,但不要显示你在那里”。除了将index.php作为Apache中的默认文档(使用DirectoryIndex,正如Hamish在下面回答的那样),您无法真正控制用户在地址栏中看到的内容。@Marc,您当然可以–这就是HTTP重定向的用途。
index.php
→ <代码>/外部,/
→ index.php
internal,非常合理:)呵呵,我的意思是:用户键入www.domain.com,他被重定向到www.domain.com/index.php,但它保持在www.domain.com。基本上,index.php成为默认页面。这就是DirectoryIndex的用途。它指定了当URL没有直接指定某个文件(如www.domain.com和www.domain.com/)时,Apache应该使用哪个文件作为默认文档。我不编辑它,但它似乎不起作用。我可能做错了什么。这将在地址中显示http:/your.domain.php/index.php
,OP希望http:/your.domain.php/
hummm似乎不起作用。我在我的问题中写了我的.htaccess。@Elggetto:不工作不是真正的答案。当你访问www.domain.com时,它会做什么?是的,对不起。它直接进入www.domain.com/index.html(我有一个临时index.html只是为了测试)那么,你确定有index.php页面吗?通常apache+PHP服务器配置为使用index.PHP,如果没有index.html,则使用index.html作为默认索引页。htaccess文件可能会覆盖此选项,也可能不会覆盖,这取决于您的apache配置。如果您无法访问该信息,并且确信index.php在这里,在good文件夹中,我建议您删除index.html,并使用test.html进行测试;)。。。就这么简单。谢谢。我只需要删除index.html就可以了!
RewriteEngine On
RewriteBase / # URL path corresponding to this directory
RewriteRule (^|.*/)index\.php$ $1 [R]