RewriteRule上的.htaccess重定向问题

时间:2011-08-11 07:50:27

标签: apache .htaccess mod-rewrite

我希望http://www.mycom/api/*mycom/api/index.php文件路径

RewriteEngine On
#1 
RewriteRule ^api/([a-zA-Z]+)  /mycom/api/index.php?mode=$1 [QSA,L]

导致内部服务器错误

#2
RewriteRule ^/api/([a-zA-Z]+)  /mycom/api/index.php?mode=$1 [QSA,L]
# 3
RewriteRule ^mycom/api/([a-zA-Z]+)  /mycom/api/index.php?mode=$1 [QSA,L]

2和3不起作用

1 个答案:

答案 0 :(得分:2)

index.php的真实网址是什么? http://www.mycom/api/index.phphttp://www.mycom/mycom/api/index.php

在第一种情况下试试这个:

RewriteRule ^api(/.*)? /api/index.php?mode=$1 [QSA,L]

如果是第二个

RewriteRule ^api(/.*)? /mycom/api/index.php?mode=$1 [QSA,L]

BTW,您是否需要原始查询字符串和模式参数?