这是我在.htaccess中的代码:
Options -Multiviews
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^home$ home.php [L]
使用此代码,网址www.example.com/home可以正常运行,但不会从www.example.com/home.php重定向到www.example.com/home
使用此代码:
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重定向到家并避免错误?
答案 0 :(得分: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]