【发布时间】:2011-06-06 14:14:23
【问题描述】:
我正在尝试在我的网站上添加一些重写,但它似乎不起作用,我正在使用 apache 和 .htaccess。
我的 .htaccess 文件中的代码是:
RewriteEngine On
RewriteRule ^/?os_framework/?$ /os_framework/index.php?module=home [L,NC,QSA,PT]
这应该将http://localhost/os_framework/ 发送到http://localhost/os_framework/index.php?module=home 但似乎没有。
任何帮助将不胜感激。
提前谢谢
编辑:已修复上述问题,搜索模式中不应包含 os_framework/,但现在我无法使用它:
RewriteRule ^/(.[^/]*)/?$ /os_framework/index.php?module=$1 [L,NC,QSA,PT]
还有什么问题
RewriteRule ^(.[^/]*)/?$ /os_framework/index.php?module=$1 [L,NC,QSA,PT]
为什么会抛出错误 500?它应该工作
【问题讨论】:
-
你为什么在搜索模式上使用
?s...你试过没有吗? -
?s告诉它之前的标识符可以是可选的,因此它会对os_framework和os_framework/做出反应 -
到底发生了什么? 404找不到错误还是什么?无论如何,出于调试目的,您可以尝试
RewriteRule ^os_framework/?$ os_framework/index.php?module=home [R],这样您就可以看到 Apache 是否以及正在将您的 URL 重写为什么。 -
但是你为什么要在 前导 斜线后面紧跟一个
?呢?路径总是/os_framework,对吧? -
它只是加载没有参数的默认索引文件,
[R]不显示任何内容
标签: apache .htaccess mod-rewrite