【问题标题】:redirecting domain to index.php via php script通过 php 脚本将域重定向到 index.php
【发布时间】:2013-07-08 13:23:56
【问题描述】:
我无法让我的网站自动从我的域重定向到我的 index.php 文件,也就是说,我不能:
当我输入 www.mysite.com 时 www.mysite.com ==> www.mysite.com/index.php
我无法编辑任何 .htacces 或类似的配置文件,因为我的网站托管在不允许我编辑此类文件的托管服务提供商上。
我有办法使用一些 php 脚本,能够将我的主域重定向到 index.php 吗?
谢谢
M.
【问题讨论】:
标签:
php
redirect
indexing
【解决方案1】:
如果你能够编辑你的 .htaccess,你可以使用这个:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$
RewriteRule ^$ http://www.example.com/index.php [L,R=301]
但如果您不是,那么您可以将其添加到您的 index.html 文件中:
<meta http-equiv="refresh" content="1;url=http://www.mysite.com/index.php">
这是一个可以接受的解决方案并且工作得很好,但它肯定不是最好的解决方案。
希望这会有所帮助!
【解决方案2】:
从您的站点中删除index.html 页面,然后添加index.php 页面,
它将重定向到www.mysite.com/index.php