dsbifvcxr458755493 2013-10-05 21:16
浏览 40

htaccess:重写规则不起作用

I want 'contact' to be changed into index.php?controller=Front&action=$1&page=12 and I get a 404:

The requested URL /symfony/LocAtMe/web/contact was not found on this server"

This is the code in my htaccess:

AddType application/x-httpd-php .tpl .inc
<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule ^$ index.php?controller=default&action=index [QSA]
    RewriteRule ^contact$ index.php?controller=Front&action=$1&page=12 [QSA, L]
    RewriteRule ^([a-zA-Z0-9]+)$ index.php?page=$1 [QSA]
</IfModule>

Any help much appreciated.

  • 写回答

2条回答 默认 最新

  • duan5991518 2013-10-06 00:21
    关注

    You can't have a space after the QSA, in the rewrite flags:

    RewriteRule ^contact$ index.php?controller=Front&action=$1&page=12 [QSA,L]
    # can't have a space here ----------------------------------------------^
    

    Though that shouldn't cause the 404. You should also double check that you have mod_rewrite loaded. If it's not loaded, removing the <IfModule mod_rewrite.c> and </IfModule> lines should cause a 500 error.

    评论

报告相同问题?

悬赏问题

  • ¥20 Keil编译时报错"no source": Error: #5: cannot open source
  • ¥50 操作系统时间无法更新
  • ¥20 Windows11, usb转hdmi,外接显示器无反应
  • ¥20 怎么在JavaFx的TableView中动态地添加数据。
  • ¥15 MFC里的工具栏按钮图标使用外部图片
  • ¥15 如何在 llama.cpp 服务器中实现用户登录功能的优化方案?(语言-c++)
  • ¥15 有会用octave 的吗,急!代做!好偿!
  • ¥15 有一套同城小程序源码,Uniapp前端,php+html+mysql后端 ,能不能教我搭建起来可以运行,我不知道怎样操作
  • ¥15 mac调用java.io接口无法在根目录生成文件
  • ¥15 java微服务节点假死,网关路由时长延迟