0

One of my interns applied a 301 redirect on one of the site's pages (domain.com/nice-page) to another page (domain.com/pretty-page) and I'd like to remove that redirect.

The problem is that he is not sure from where the redirect was applied.

He says he did it via a plugin but I have thoroughly checked the redirection plugins on my site and couldn't find any redirect rules.

I have also checked the .htaccess and couldn't find any rules either.

Could you guys please let me know if there's a way to find the source of the redirect (some magic like the inspect element for html and css issues)?

I'd really appreciate any help in this regard.

2
  • If its a plugin it will be difficult to find the plugin as the page will be rendered by the time you see it. What is the CMS? Wordpress? Joomla ? – Mike Jul 19 '18 at 11:20
  • Hi Mike, yeah. It's WordPress. I can say for sure that it's not due to the plugin as I have personally checked the one and only redirection plugin on my site and it has no records of any redirects for that particular post. – Naser Mohd Baig Jul 19 '18 at 18:30
2

A permanent redirect Header (HTTP status code 301) can originate from roughly 3 locations on an Apache web server:

  • From the main Apache httpd.conf configuration file or one of the Includes loaded by the httpd.conf file.
  • If AllowOverride is set it can be set from any .htaccess file in the path of the URL that gets redirected.
  • From "code" (PHP, CGI scripts etc.) that gets executed by the web server.

And don't overlook alternative #4

  • "code" (Javescript, JQuery etc.) that gets executed by the web browser.

Apache Redirect headers can be set with either mod_alias with the Redirect , RedirectMatch or RedirectPermanent directives or with a mod_rewrite R flag.

How "code" does that depends and will be a PITA to determine, but running a dumb web request (e.g. curl -v http://example.com/nice-page) will show you if indeed a HTTP/1.1 301 Moved Permanently \n Location: http://... response gets triggered by the web server as a Header, or if that is not the case then you should look at browser scripts.

Also note: a HTTP 301 Redirect is "Moved Permanently" and as such will be cached by both web browsers, CDN's and proxy servers and after you have removed the directive from a server config you may still observe it. You may need to test from a new anonymous browser window and/or clear your caches.


From your comment with the URL:

curl -v http://photographyconcentrate.com/camera-buying-guide
*   Trying 104.27.188.166...
* TCP_NODELAY set
* Connected to photographyconcentrate.com (104.27.188.166) port 80 (#0)
> GET /camera-buying-guide HTTP/1.1
> Host: photographyconcentrate.com
> User-Agent: curl/7.54.0
> Accept: */*
>
< HTTP/1.1 301 Moved Permanently
< Date: Fri, 20 Jul 2018 11:26:41 GMT
< Transfer-Encoding: chunked
< Connection: keep-alive
< Cache-Control: max-age=3600
< Expires: Fri, 20 Jul 2018 12:26:41 GMT
< Location: https://photographyconcentrate.com/camera-buying-guide
< Server: cloudflare
< CF-RAY: 43d5130783252b40-AMS

That shows that your domain is using CloudFlare, a CDN and is indeed implemented with a 301 Moved Permanently redirect header and not via java script. That adds a complication, as the redirect can also be set on CF, and need not even be present on your webserver.

You can confirm if the redirect gets sent from your webserver or only by CloudFlare by by-passing CloudFlare and running:

 curl -v -H "Host: photographyconcentrate.com" http://<real-IP-address-of-your-webserver>/
6
  • Hi @HBrujin, I ran a curl command for my old URL and it returned this info: dropbox.com/s/duxs2exc6hpd5qo/… Can you please help me identify the source from that? I can send you the URL if you'd like to run that command yourself. Thanks again. – Naser Mohd Baig Jul 19 '18 at 18:52
  • Sure, No problem – HBruijn Jul 19 '18 at 20:11
  • Thank you, the URL is photographyconcentrate.com/camera-buying-guide I owe you one – Naser Mohd Baig Jul 20 '18 at 6:09
  • You are using CloudFlare, that is option #5 - the redirect may be effected from the control panel there as for instance a "page rule" - see my edit – HBruijn Jul 20 '18 at 11:29
  • 1
    There aren't any WordPress-specific headers in that HTTP response, so CloudFlare would be my guess. – Michael Hampton Jul 23 '18 at 13:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.