0

这是我在 .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 重定向到 home 并避免错误?

4

1 回答 1

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]
于 2012-06-09T09:27:24.160 回答