如何将网站重定向到特定文件?

时间:2011-11-22 16:34:47

标签: php .htaccess

有一个域名。我们说domain.com

当用户仅键入domain.com时,应将其重定向到地址domain.com/file.html。如何使用.htaccess文件执行此操作?

另外,RewriteRule ^index\.php$ - [L]是什么意思?它对我有帮助吗?

3 个答案:

答案 0 :(得分:0)

添加到.htaccess文件

DirectoryIndex file.html 

答案 1 :(得分:0)

查看此网站:.htaccess tricks and tips这是重写规则的一个很好的参考。

至于RewriteRule ^ index.php $ - [L]是什么意思。它将忽略index.php结尾Rewrite Rule meaning

的任何内容

答案 2 :(得分:0)

尝试将以下内容放在domain.com

根目录下的.htaccess文件中
RewriteEngine On
RewriteBase /

#put all the following rules before any other rules in the .htaccess file
RewriteRule ^file\.html$ - [L]

#domain.com or any subdomain 
RewriteCond %{HTTP_HOST} ^(.+)\.domain\.com$ [NC]
#the root of domain   
RewriteCond %{REQUEST_URI} ^/?$ [NC]
#return file.html
RewriteRule . file.html [L]
相关问题