/删除/ URL重写Apache中的POST PUT [英] URL rewrite in Apache for POST/DELETE/PUT

查看:228
本文介绍了/删除/ URL重写Apache中的POST PUT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的网址是这样

http://10.243.123.1/v1/data/register

我要重定向/重写这个网址

I want to redirect/rewrite this url to

https://10.243.123.1/data/register  (This is HTTP POST/PUT/DELETE url)

1.should remove v1 and make https

2.If url does not contains v1 then just make https alone.

什么规则应该在需要在httpd.conf文件中添加??

What rule should in need to add in httpd.conf file..??

无论规则去的httpd.conf或.htacccess文件?

Whether rule goes to httpd.conf or .htacccess file?

请分享你的想法

推荐答案

将这个code在 DOCUMENT_ROOT /的.htaccess 文件:

Put this code in your DOCUMENT_ROOT/.htaccess file:

RewriteEngine On

RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{THE_REQUEST} \s/+v1/(\S+) [NC]
RewriteRule ^ https://%{HTTP_HOST}/%1? [R=302,L,NE]

RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=302,L,NE]

RewriteRule !^v1/ /v1%{REQUEST_URI} [NC,L]

这篇关于/删除/ URL重写Apache中的POST PUT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆