URL rewrite in Apache for POST/DELETE/PUT

后端 未结 1 1334
旧巷少年郎
旧巷少年郎 2021-01-23 17:11

I have my url like this

http://10.243.123.1/v1/data/register

I want to redirect/rewrite this url to

https://10.243.123.1/data/r         


        
相关标签:
1条回答
  • 2021-01-23 17:56

    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]
    
    0 讨论(0)
提交回复
热议问题