Coder Coder - 2 years ago 120
Apache Configuration Question

Replace some parts of url with htaccess

I want to replace some parts of url using htaccess.

I am using below code but i am getting 404 error.

RewriteRule ^/v1/surveys/login(.*)$ /oauth2/rest/token/$1 [R=301,L]

This is my url and i want to

replace with

Answer Source

You can use this rule just below RewriteEngine On line:

RewriteEngine On

RewriteCond %{REQUEST_URI} ^/(survey/api)/v1/surveys/login(/.*)?$ [NC]
RewriteRule ^ /%1/oauth2/rest/token%2 [R=301,L,NE]

# rest of the rules go below this

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download