htaccess redirect example.com/index.php to example

2019-09-05 04:48发布

Thanks in advance, I am trying to redirect anyone who types in example.com or example.com/index.php to example.com/home

Please let me know, I have tried the htaccess rules of redirect permanent and 301's and they have not worked. My pages are created dynamically.

2条回答
SAY GOODBYE
2楼-- · 2019-09-05 05:31

Couldn't you just put a php script to redirect visitors? The following should work, save it as index.php in your root directory.

<?
Header( "HTTP/1.1 301 Moved Permanently" ); 
Header( "Location: http://www.yoursite.com/home" ); 
?> 
查看更多
甜甜的少女心
3楼-- · 2019-09-05 05:36

First, make sure your syntax is correct. Is this what your .htaccess file looked like?

Redirect 301 / http://example.com/home
Redirect 301 /index.php http://example.com/home

If you're sure, try this:

RewriteEngine on
RewriteBase /
RewriteRule ^& http://example.com/home [L,R=301] 
RewriteRule index.php http://example.com/home [L,R=301]
查看更多
登录 后发表回答