Thursday, September 1, 2022

[SOLVED] .conf file to redirect naked domain to page

Issue

I have a Craft CMS site, which has generated a specific page–let's call it "domain.com/page-x"–and I want to edit a .conf file for a new domain to redirect domain2.com straight to this page.

Thing is that since it's not a flat file, I can't use DocumentRoot to point directly to it in the server, so I've used Redirect permanent, but I'm not sure if that'll work at intended:

<VirtualHost *:80>
  ServerName domain2.com
  ServerAlias www.domain2.com

  Redirect permanent / domain.com/page-x

  CustomLog /var/log/httpd/website.lc-access.log combined
  ErrorLog /var/log/httpd/website.lc-error.log

</VirtualHost>

Is this correct?


Solution

The correct way:

Redirect permanent / http://domain.com/page-x/
  1. Always include the scheme (http/https)
  2. Always match slashes in source and target.


Answered By - ezra-s
Answer Checked By - Dawn Plyler (WPSolving Volunteer)