-1

Problem statement:

How to redirect example.com to example.com/mypath/mypage from vhost file

Configurations done:

  1. Added below entries in vhost SSL and on SSL both & restarted httpd
    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^www.example.com [NC]
    RewriteRule ^(.*)$ https://www.example.com/mypath/mypage  [L,R=301]
    
    

Issue: If user type example.com it should go to https://www.example.com/mypath/mypage, it's not happening

Stephen Ostermiller
  • 23,933
  • 14
  • 88
  • 109
Azhar
  • 933
  • 1
  • 12
  • 28

1 Answers1

0

you can use Apache's mod_rewrite module.

Open the vhost file for the domain you want to redirect. Add the following lines of code to the file:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^$ /mypath/mypage [L,R=301]

Change

RewriteRule ^(.*)$ https://www.example.com/mypath/mypage  
[L,R=301]

By

RewriteRule ^$ /mypath/mypage [L,R=301]
Stephen Ostermiller
  • 23,933
  • 14
  • 88
  • 109
Stéphane
  • 443
  • 1
  • 7
  • 20