[英]rewrite url based on specific sub-directory using.htaccess
I am wondering whether it's possible to use .htaccess to search for a particular folder that starts with a number and redirects internally without changing the URL in the browser. 我想知道是否可以使用.htaccess搜索以数字开头并在内部重定向而不更改浏览器中URL的特定文件夹。
Lets say I have a url like: 可以说我有一个网址,例如:
www.example.com/api/rest/3.22/user
Now I want to rewrite the url internally to (for example) 现在,我想在内部将网址重写为(例如)
www.example.com/api/rest/3.0/user
Note: Only the 3.0 folder available in server and 3.22 is just a name. 注意:只有服务器中可用的3.0文件夹和3.22才是名称。
I tried with the following one,but it not helps. 我尝试了以下方法,但没有帮助。
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.