[英]rewrite url based on specific sub-directory using.htaccess
我想知道是否可以使用.htaccess搜索以數字開頭並在內部重定向而不更改瀏覽器中URL的特定文件夾。
可以說我有一個網址,例如:
www.example.com/api/rest/3.22/user
現在,我想在內部將網址重寫為(例如)
www.example.com/api/rest/3.0/user
注意:只有服務器中可用的3.0文件夾和3.22才是名稱。
我嘗試了以下方法,但沒有幫助。
RewriteRule ^api/rest/3\.22/$ /api/rest/3.0/$1
在您的根.htaccess中嘗試以下規則:
RewriteRule ^(api/rest)/(?!3\.0/)[\d.]+/(\w+)$ /$1/3.0/$2 [L,NC]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.