skip to Main Content

I just wonder which app is in charge of URL redirection in a WordPress site.

In my site, there is a real folder at /downloads/files/. Now I find there are some 404 errors in accessing https://www.datanumen.com/downloads/files/sitemap.xml, so I want to redirect the URL to https://www.datanumen.com/sitemap.xml

I try several methods:

  1. Add the following redirect in .htaccess in the root folder:
Redirect 301 /downloads/files/sitemap.xml https://www.datanumen.com/sitemap.xml

But that does not work.

  1. Install Redirection plugin and setup a redirection from

/downloads/files/sitemap.xml

to

/sitemap.xml

But still not work.

So I am curious that in a WordPress site, when I input a URL, will the URL be processed by WordPress system first(in which method 2 will take effect), or processed by Apache first(in which method 1 will take effect)? Why both methods do not work?

2

Answers


  1. client sends ip packet to a host and specifies that the data in the ip packet is for a particular port number, apache listens on specific port numbers as do most network applications, if the ip packet is for one of the port numbers apache is listening on the operating system will route the ip packet to apache, apache then can see a request for file i.e. html,pdf,jpeg,etc. apache then retrieves that file,image,etc from the server storage medium i.e. ssd or hdd, if the file contains php code then apache will parse the php itself before serving the file to the client.

    1. hardware for server computer i.e. cpu,gpu,ram,memory
    2. operating system i.e. linux
    3. server app than run on the operating system i.e. apache
    4. php files i.e. wordpress

    So basically Apache acts first i.e. the server configuration files then when Apache parses the wordpress php files, the php script is executed secondly.

    Login or Signup to reply.
  2. Apache/.htaccess catches the request first. It is Apache that sends the request to WordPress/PHP.

    However, looking at the HTTP response in the browser…

    cf-cache-status: HIT
    server: cloudflare
    

    The 404 response you are seeing is coming from your CDN’s cache. The request isn’t even reaching your application server in order to process the redirect.

    /downloads/files/sitemap.xml
    

    HOWEVER, are these legitimate requests for your sitemap XML file? This seems unlikely. So, I’d question whether these requests need to be redirected in the first place?

    Note that /sitemap.xml is itself redirected to /wp-sitemap.xml so /sitemap.xml would not seem to be the correct target anyway.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search