2012-06-09 32 views
0

这是我在.htaccess代码:如何从home.php重定向到家?

Options -Multiviews 
Options +FollowSymlinks 
RewriteEngine on 
RewriteRule ^home$ home.php [L] 

这段代码的URL www.example.com/home的工作,但它不会从www.example.com/home.php重定向到www .example.com的/家

有了这个代码,而不是:

Options -Multiviews 
Options +FollowSymlinks 
RewriteEngine on 
RewriteRule ^home$ home.php [R=301,L] 

我得到这个错误:

Not Found 

The requested URL /var/chroot/home/content/08/236108/html/home.php was not found on this server. 

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. 

如何从home.php重定向到主页并避免错误?

回答

1
Options -Multiviews 
Options +FollowSymlinks 

RewriteEngine on 
RewriteBase/

RewriteRule ^home$ home.php [L] 

RewriteCond %{THE_REQUEST} home\.php 
RewriteRule ^home.php$ home [R=301,L]