簡體   English   中英

RewriteRule 上的 .htaccess 重定向問題

[英].htaccess redirect issue on RewriteRule

我想要任何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也不行

index.php 的真正 url 是什么? http://www.mycom/api/index.php or http://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]

順便說一句,您需要原始查詢字符串和模式參數嗎?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM