Apache Mod_Rewrite帮助

时间:2011-06-08 11:52:50

标签: apache mod-rewrite

我正在尝试将子目录转换为变量以供查询使用。

e.g。

domain / subdir / STRING (需要“ STRING ”子目录)

转换为:

域/子目录/的index.php?Q = STRING

我所得到的只是内部服务器错误以及404和phpinfo(),原因有些奇怪。

P.S。

已尝试此页面上的信息:http://corz.org/serv/tricks/htaccess2.php

编辑:

这似乎有效。 RewriteRule ^([a-zA-Z0-9] +)$ index.php?qst = $ 1

但它限制了与AlphaNum字符的匹配,我想包括, - ,_和#如果可能的话。

2 个答案:

答案 0 :(得分:0)

RewriteRule ^subdir/index\.php(.*) - [L]
RewriteRule ^subdir/(.*)$ /subdir/index.php?q=$1 [L]

答案 1 :(得分:0)

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^subdir/(.*)$ /subdir/index.php?q=$1

RewriteCond检查所请求的文档是否不是现有文件,这样我们就不会对index.php进行递归调用

下一条规则是请求/subdir/index.php的常见重写。

相关问题