douyou8047 2016-11-16 06:25
浏览 99
已采纳

404错误页面使用htaccess重定向到主页

I need to redirect 404 error page to home page.

I used below code to redirect 404 page to home page but this code working in one scenrio.

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ /index.php [L]

It's working for www.domain.com/slug1 this type of URL

But it's not working for www.domain.com/slug1/slug2/slug3.... this type of urls.

Please suggest any solution for this issue.

  • 写回答

1条回答 默认 最新

  • dongzanghua8422 2016-11-16 06:43
    关注

    Try this

    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule . / [L,R=301]
    
    ErrorDocument 404 /index.php
    

    Look Here For More Help

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号