【问题标题】:How to redirect from home.php to home?如何从 home.php 重定向到 home?
【发布时间】:2012-06-09 08:22:22
【问题描述】:

这是我在 .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 并避免错误?

【问题讨论】:

    标签: apache .htaccess mod-rewrite


    【解决方案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]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-07-16
      • 1970-01-01
      • 2021-01-24
      • 2016-12-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多