简体   繁体   中英

.htaccess redirect issue on RewriteRule

I would like to have any http://www.mycom/api/* route to the mycom/api/index.php file

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

cause Internal Server Error

#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 and 3 don't work either

what is the real url for index.php? http://www.mycom/api/index.php or http://www.mycom/mycom/api/index.php ?

in the first case try this:

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

if it's the second

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

BTW, do you need both the original query string and the mode parameter?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM