If you notice a redirect on your domain and are unsure of its source, you can often find out where the redirect is coming from by checking the HTTP headers. One simple method to achieve this is by using the cURL command over SSH.
What Is cURL and What Can It Do?
cURL is a powerful command-line tool that allows you to interact with websites and retrieve information from their servers. It is widely used for checking website status, fetching web pages, and diagnosing issues like unexpected redirects.
Prerequisites
- Access to your server via SSH
- Basic knowledge of SSH commands
- Domain name pointing to your server
Steps to Identify Redirect Sources Using cURL
- Log in to your server via SSH.
- Run the following command, replacing
example_domainname.com
with your actual domain:
curl -I example_domainname.com
- After running the command, you will see an output similar to the following:
curl -I yourdomain.com
HTTP/1.1 303 See Other
Date: Fri, 23 Jul 2021 05:04:24 GMT
Server: Apache
X-Redirect-By: WordPress
Content-Language: en
Location: https://yourdomain.com
Content-Type: text/html; charset=UTF-8
- Look for the X-Redirect-By header in the output. This line will tell you the source of the redirection.
Common Redirect Sources
Many Content Management Systems (CMS) use the X-Redirect-By
header to indicate the source of the redirect. Below are some common headers:
- X-Redirect-By: WordPress - Indicates that the redirect is managed by WordPress.
- X-Redirect-By: Joomla - Indicates that the redirect is handled by Joomla.
- X-Redirect-By: Moodle - Shows that Moodle is responsible for the redirect.
By using the cURL command, you can easily identify the source of any unexpected redirects on your domain. This method is particularly useful when dealing with websites powered by a CMS like WordPress, Joomla, or Moodle. If you discover a redirect that you weren’t aware of, you can further investigate and resolve it based on the output provided by cURL.
For more information on how to diagnose website issues using cURL, check out the official cURL documentation.