.htaccess rewrite rules to new domain name & path (retain file name)

46 Views Asked by At

This is our 1st attempt with .htaccess scription. Please help us with the below requirement:

Actual URL: https://domaina.com/Criteria1/valueaddedcourse/2202223742-first aid course.pdf

If the URL Contains "/Criteria1/valueaddedcourse/" then it should redirect to a new domain & path but with same file name (2202223742-first aid course.pdf)

https://qaanr.s3-ap-south-1.amazonaws.com/2202223742-first aid course.pdf

Being a newbie, find apache tutorial too cryptic (https://httpd.apache.org/docs/2.4/howto/htaccess.html)

Please do share content with details description for .htaccess - this will help us to learn.

==== Update to above question ===

this code works for me:

` RewriteEngine On RewriteCond %{REQUEST_URI} ^/Criteria1/valueaddedcourse/ RewriteRule ^(.*) https://qaanr.s3-ap-south-1.amazonaws.com/% {REQUEST_FILENAME} [P]

`

this code works for redirection, Fails to mask. Browser has to show the original domain name & not https://qaanr.s3-ap-south-1.amazonaws.com/

1

There are 1 best solutions below

1
Muhammad Rizwan On

RewriteEngine on

RewriteCond %{REQUEST_URI} ^/Criteria1/valueaddedcourse/

RewriteRule ^(.*)$ https://qaanr.s3-ap-south-1.amazonaws.com/$1 [R=301,L]

Usage = If the URL Contains "/Criteria1/valueaddedcourse/" then it will redirect to a new domain & path but with same file name (2202223742-first aid course.pdf)