dongyu3712 2014-04-26 03:25
浏览 25
已采纳

htaccess在同一个文件中有两个命令

Hi i have my htaccess with this:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ $1.htm [L]

ErrorDocument 404 /404.htm

if i erase the first 4 lines, the other piece of code (which redirects de 404 page when there's a page not found) does not work anymore.

Any ideas? I also want that when it redirects to 404.htm, it does not show on the url box, this url

http://www.mypage.com/404.htm

i want to show this

http://www.mypage.com/fail/search-by-the-user

for example.

  • 写回答

1条回答 默认 最新

  • duan19850312 2014-04-26 03:37
    关注

    Try following .htaccess

    RewriteBase /
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME}\.html -f
    RewriteRule ^(.*)$ /$1.html
    
    ErrorDocument 404 /404.html
    

    NOTE: if you are working at localhost then please mention proper RewriteBase

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

报告相同问题?

悬赏问题

  • ¥60 pb数据库修改或者求完整pb库存系统,需为pb自带数据库
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路