将文件扩展名替换为htaccess重定向中的文件夹(Replace file extension with folder in htaccess redirect)

编程入门 行业动态 更新时间:2024-10-26 19:38:50
将文件扩展名替换为htaccess重定向中的文件夹(Replace file extension with folder in htaccess redirect)

我需要重新格式化具有结构的URL

http://www.example.com/vaservice/ServiceController.svc?v1=d1&v2=d2& ...

http://www.example.com/vaservice/ServiceController/svc?v1=d1&v2=d2& ...

我用这个htaccess代码从url中删除了.svc,但我无法弄清楚如何替换。 使用/而不是仅删除扩展名。

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.svc [NC] RewriteRule ^ %1 [R,L] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}.svc -f RewriteRule ^(.*?)/?$ $1.svc [L]

I need to reformat a url with the structure

http://www.example.com/vaservice/ServiceController.svc?v1=d1&v2=d2&...

to

http://www.example.com/vaservice/ServiceController/svc?v1=d1&v2=d2&...

I have removed the .svc from the url with this htaccess code but I cannot figure out how to replace the . with a / instead of just removing the extension.

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.svc [NC] RewriteRule ^ %1 [R,L] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}.svc -f RewriteRule ^(.*?)/?$ $1.svc [L]

最满意答案

想出来谢谢!

RewriteCond %{THE_REQUEST} ^[AZ]{3,}\s([^.]+)\.svc [NC] RewriteRule ^ %1/svc [R,L]

Figured it out thanks!

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.svc [NC] RewriteRule ^ %1/svc [R,L]

更多推荐

本文发布于:2023-08-06 21:17:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1455367.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件夹   重定向   文件扩展名   htaccess   Replace

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!