简体   繁体   English

如何使用htaccess将website.com/和website.com/index.php重定向到另一个页面

[英]How to redirect website.com/ and website.com/index.php to another page with htaccess

I can redirect website.com/index.php to website.com/home but I can't find a way to redirect website.com to website.com/home 我可以将website.com/index.php重定向到website.com/home但我找不到将website.com重定向到website.com/home

I have tried RewriteRule ^/$ /home [R=301] but it does nothing. 我试过RewriteRule ^/$ /home [R=301]但它什么也没做。

Try this 试试这个

RewriteEngine on 
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www\.)?website\.com$ [NC] 
RewriteRule .* http://www.website.com/home [R=301,L] 

This rule redirects www.website.com to www.website.com/home 此规则将www.website.com重定向到www.website.com/home

Or add this to your .htaccess 或者将此添加到.htaccess

RewriteRule ^/?$ /home [R=301,L] 

单个规则可以处理两个重定向:

RewriteRule ^/?(index\.php)?$ /home [NC,L,R=301]

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在其编辑器中隐藏自定义website.com网站菜单 - How to hide your custom website.com website menu in their editor 显示 website.com/login 而不是 website.com/login.html - Showing website.com/login instead of website.com/login.html 路径中带有用户名的网站,例如: website.com/username - Website with username in path like: website.com/username HTML导航错误。 如何处理www.website.com与website.com? 在html中正确导航? - HTML Navigation Error. How to handle www.website.com versus website.com? Correct navigation in html? 是否可以从此类网址获取信息:website.com/hello/richard - Is it possible to get information from this type of url: website.com/hello/richard 如何配置htaccess删除index.php并在错误404时重定向 - How to configure htaccess to remove index.php and redirect if error 404 如何链接到我网站上除index.php之外的页面(其他所有页面均导致错误)? - How to link to page other than index.php on my website (all other pages result in error)? 对于以表单结尾的单页网站:是否必须将index.html转换为index.php? - For a Single-Page-Website with a form at the end: Do I have to convert the index.html into index.php? 如何使用example.com/index.php?ref=origin跟踪用户来源PHP - How to track users origin PHP by using example.com/index.php?ref=origin 通过google访问时,网站显示为空白,但如果您进入index.php页面,则加载正常 - Website appears blank when accessed through google, but loads fine if you go to index.php page
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM