apache force if url has specific pattern redirect to https [duplicate]

This is very simple using mod_rewrite:

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(foo|bar)$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]

This will rewrite any URL that matches the pattern in the RewriteRule to the same URL over HTTPS.


You can try mod_alias - Apache HTTP Server Redirect Directive.

Example:

Redirect /service http://foo2.example.com/service 

* UPDATE *

Redirect /admin-2dns24dw https://examplesite.com/fa/dashboard