.htaccess 重定向到其他页面-htaccess
当用户键入我的站点的url(例如www.domain.com)时,我想将其重定向到一个名为test.php的页面。.htaccess 重定向到其他页面-htaccess,.htaccess,.htaccess,当用户键入我的站点的url(例如www.domain.com)时,我想将其重定向到一个名为test.php的页面。 实际上,通过键入www.domain.com,浏览器应该在index.html或index.php上显示www.domain.com/test.php,您可以添加如下元刷新标记: <meta http-equiv="refresh" content="5;www.domain.com/test.php" /> <IfModule mod_rewrite.c>
实际上,通过键入www.domain.com,浏览器应该在index.html或index.php上显示www.domain.com/test.php,您可以添加如下元刷新标记:
<meta http-equiv="refresh" content="5;www.domain.com/test.php" />
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com [NC]
RewriteRule (.*) http://example.com/test.php [L]
</IfModule>
如果使用index.php,语法如下:
echo '<meta http-equiv="refresh" content="5;www.domain.com/test.php" />';
echo';
如果要重定向到另一个域,请在url处添加http://。在.htaccess文件顶部尝试此规则(文件和目录除外,请将任何内容从www/non-www重写到example.com/test.php)
重新启动发动机
重写基/
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写cond%{HTTP_HOST}^(www\)?示例\.com[NC]
重写规则(.*)http://example.com/test.php [L]
所以我不应该在htaccess文件中添加任何内容?就这样吧?是的。。离开它,或者有另一种方式通过htaccess进入你的头脑,但这不是必须的