Saturday, April 9, 2022

[SOLVED] How do I Redirect 410 gone using Apache/httpd.conf for an entire domain (in ONE line)?

Issue

Is it possible to do this without rewrite matches/conditions? I'd like one clean line if it is.

<VirtualHost *:80>
    ServerName subdomain.domain.tld
    ServerAlias www.subdomain.domain.tld
    
    # the following line works fine
    Redirect gone /example-nonexistent-url

    # but how do i catch the entire domain?
    Redirect gone [-what to insert here to catch the entire domain?-]

</VirtualHost>

A better way of asking this may be to ask how to:

Redirect gone http://subdomain.domain.tld

I've checked my question for already existing: to the best of my knowledge all other similar questions did not specifically ask about the entire domain (or was related to nginx).


Solution

well... I figured it out myself:

I tried using slash (/) by itself, but it did not work (which is why I made my original post).

After researching at https://apache.org... I discovered it must be enclosed with quotes ("/")... but no explanation was given. I only know through experimentation to prove it.

<VirtualHost *:80>
    ServerName subdomain.domain.tld
    ServerAlias www.subdomain.domain.tld

    Redirect gone /example/nonexistent/path
    
    # this works for the domain itself
    Redirect gone "/"

    # this DOES NOT work!
    # Redirect gone /

</VirtualHost>


Answered By - aequalsb
Answer Checked By - Mary Flores (WPSolving Volunteer)