index.php inserted into URL using htacess redirect

Robert Gombos

Registered
Jul 28, 2019
2
1
1
Romania
cPanel Access Level
Root Administrator
I have noticed some strange stuff regarding one of our websites. In ahrefs.tld, the "Broken Backlinks" shows some strange things.

  • PHP/5.6.40
  • Server Version: Apache/2.4.39 (cPanel) OpenSSL/1.0.2s mod_bwlimited/1.4
  • PHP-FPM not enabled
  • Cloudflare has no implication in this. Tested it with and without it.
.htaccess content:

[Moderator Note: The full contents of the .htaccess file was removed because it's not required here]

[Moderator Note: Removed link to third-party image hosting website. Please upload images directly to the thread as attachments]

I have checked the redirects, they all work as intended. In the sitemap there is no error whatsoever. The issue only occurs, as it seems, when an old backlink is crawled by ahref.tld's crawler. Same thing in Majestic.

Note: Yes, I need to use PHP5.6 because parts of the code are deprecated in newer versions.

A normal hyperlink's code to a non https version of a page looks good:

Code:
<a href="http://www.example.tld/maincategoryname/subcategory/page,1.html" class="anchor" target="_blank" rel="noopener noreferrer" title="Dofollow backlink">more helpful hints</a>
Now, according to the report, this is 301 redirected to it's https version (as it should). HOWEVER, /index.php/ is inserted into the URL:


which is, obviously, a 404 page.

Please notice the substitution of /maincategory/ with /index.php/

The corect 301 redirect result should be, of course:


So, the 301 redirect rules does work for redirecting http://www -> https://www. But why the /index.php/ is replacing the /maincategory/?

The 301 redirect rules from the top of the .htaccess file should redirect anything that is:

All URLs have proper canonical headers.

In the header I have these meta tags, if these could have any importance in that regard:
Code:
<link rel="canonical" href="https://www.example.tld/" />
<meta name="MSSmartTagsPreventParsing" content="TRUE" />
<base href="https://www.example.tld/" />
It's a bit of an issue because it affects the user experience, link juice is lost and, overall, annoys me like nothing else. :) I know I am missing something, but I have no clue what.

On the live website I wasn't able to find any faulty redirect, but again, I have the SSL certificate installed for *example.tld.

So, I am guessing that it has something to do with redirecting http://www. to the https version... and probably it's missing from somewhere a backslash. /

or, more probably

there is a conflict between the DirectoryIndex directive in Apache (prioritise index.html) and cPanel-generated handler for PHP?

Reference: check out the image, versus this code from the .htaccess file:

Code:
# php -- BEGIN cPanel-generated handler, do not edit
<IfModule mime_module>
AddHandler application/x-httpd-ea-php56 .php .php5 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
Note: that the homepage is indeed an index.html file. But I have an index.php one as well which serves anything else besides the homepage.

And this is the puzzle: what could be the reason that /index.php/ path is included in the URL replacing /maincategory/.

Thank you for any suggestion!

Regards, Robert G.
 
Last edited by a moderator:

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,261
463
Hello :)

This type of issue is difficult to diagnose without access to the server to see the issue on a live domain. Can you submit a support ticket so we can take a closer look? You can post the ticket number here once it's opened and we'll update this thread with the outcome.

Thank you.