如何通过htaccess设置默认网站页面?

时间:2021-05-29 21:14:34

I am currently setting up a website from a client on his hosting account. The website address and for some reason doesn't default to .php files (that is: index.php). If I put index.php and there is no index.html file I receive the following error:

我目前正在他的托管帐户上建立一个客户的网站。网站地址由于某种原因不会默认为.php文件(即:index.php)。如果我放入index.php并且没有index.html文件,则会收到以下错误:

If you feel you have reached this page in error, please contact the web site owner: someemail@example.com If you are the web site owner, it is possible you have reached this page because: The IP address has changed. There has been a server misconfiguration. The site may have been moved to a different server. If you are the owner of this website and were not expecting to see this page, please contact your hosting provider.

如果您认为自己错误地访问了此页面,请与网站所有者联系:someemail@example.com如果您是网站所有者,则可能已到达此页面,原因是:IP地址已更改。服务器配置错误。该站点可能已移至其他服务器。如果您是本网站的所有者并且不希望看到此页面,请联系您的托管服务提供商。

His hosting is a shared hosting on cpanel.

他的托管是cpanel上的共享托管。

3 个解决方案

#1


24  

Use the DirectoryIndex directive in your .htaccess file

在.htaccess文件中使用DirectoryIndex指令

DirectoryIndex index.php

#2


3  

The problem was caused by my web-browser cache, as soon as I have cleared my cache it worked!

问题是由我的网络浏览器缓存引起的,只要我清除了它的缓存就行了!

#3


2  

Try

尝试

DirectoryIndex index.php

if that doesn't work you might have to work around it by providing index.html like

如果这不起作用,你可能需要通过提供index.html来解决它

<html><frameset rows="*"><frame src="index.php"></frameset></html>

(ofcourse more elaborate)

(当然更详细)

#1


24  

Use the DirectoryIndex directive in your .htaccess file

在.htaccess文件中使用DirectoryIndex指令

DirectoryIndex index.php

#2


3  

The problem was caused by my web-browser cache, as soon as I have cleared my cache it worked!

问题是由我的网络浏览器缓存引起的,只要我清除了它的缓存就行了!

#3


2  

Try

尝试

DirectoryIndex index.php

if that doesn't work you might have to work around it by providing index.html like

如果这不起作用,你可能需要通过提供index.html来解决它

<html><frameset rows="*"><frame src="index.php"></frameset></html>

(ofcourse more elaborate)

(当然更详细)