V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
momou
V2EX  ›  问与答

这个htaccess 要怎样写才能实现?

  •  
  •   momou · 2013-03-12 09:59:12 +08:00 · 2603 次点击
    这是一个创建于 4076 天前的主题,其中的信息可能已经有所发展或是发生改变。
    已经有一个网站abc.com,现在访问网站程序会默认转到abc.com/forum/default.htm
    现在的问题是要怎样才能实现访问网站得到的链接是:abc.com/default.htm ,而不影响现在的后台管理功能如:abc.com/manage/

    望各位不吝赐教。。。
    6 条回复    1970-01-01 08:00:00 +08:00
    revlis7
        1
    revlis7  
       2013-03-12 10:06:27 +08:00
    RewriteEngine on
    RewriteCond $1 !^(manage)
    RewriteRule ^(.*)$ forum/$1 [L]
    momou
        2
    momou  
    OP
       2013-03-12 10:24:27 +08:00
    @revlis7
    这样写直接导致服务器出错,我想可能是原来的程序写死直接访问/forum/default.htm的原因吧
    revlis7
        3
    revlis7  
       2013-03-12 10:40:34 +08:00
    @momou
    Sorry,没有测过就发出来了,这个是我写的有问题,这样试试:

    RewriteEngine on
    RewriteCond $1 !^(manage|forum)
    RewriteRule ^(.*)$ forum/$1 [L]
    momou
        4
    momou  
    OP
       2013-03-12 11:42:32 +08:00
    @revlis7 这样可以访问,但后台程序还是会报错,排除所有其它目录都不行,所以问题应该还是在程序上?
    还是有一个办法只把/forum/目录的文件重写?
    revlis7
        5
    revlis7  
       2013-03-12 13:40:21 +08:00
    @momou
    那要看具体报什么错了,也许后台页面中不仅仅包含manage目录下的内容,或者代码里有其他冲突。
    momou
        6
    momou  
    OP
       2013-03-12 16:13:50 +08:00
    @revlis7
    终于找到问题了。。。
    RewriteCond $1 !^(index\.php|manage|forum)
    这样就行了。。。
    非常感谢你!
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3289 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 13:29 · PVG 21:29 · LAX 06:29 · JFK 09:29
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.