Forum Moderators: phranque

Message Too Old, No Replies

404 errors

         

WinMing

7:46 am on Apr 1, 2024 (gmt 0)



Hello every body, newbie here. I received a lot of 404 errors when I site audited our website using Semrush. All of the errors, they end with "<?php echo site_url();?>"

Can any one tell me what is going on and how I can solve it? Thanks in advance.

tangor

11:27 am on Apr 1, 2024 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Testing site vulnerabilities. Ignore. If the page does not exist then the 404 function is working properly.

@WinMing... Welcome to Webmasterworld!

not2easy

1:31 pm on Apr 1, 2024 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Hi WinMing and welcome to WebmasterWorld [webmasterworld.com]

If you really want to know what URLs are returning a 404 error, you can search your access logs. That eliminates errors from tools that could have different settings than you are using. If any URLs actually contain the "<?php echo site_url();?>" string (very unlikely) you can find those and correct them.

phranque

8:30 pm on Apr 1, 2024 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



welcome to WebmasterWorld, WinMing!

All of the errors, they end with "<?php echo site_url();?>"

if all the urls causing 404 errors end with this string, something within your PHP syntax is preventing this code from being interpreted by PHP.

WinMing

12:24 am on Apr 3, 2024 (gmt 0)



Thanks for your responses every one. I appreciate you guys. To be honest, your responses don't make sense to me because I'm not knowledgeable with codes or something. Is there an easier way I can understand your thoughts? Thanks again in advance.

not2easy

3:05 am on Apr 3, 2024 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



It is not a real error, it looks like it was caused by an error between the tool you were using and the settings of your site or host.

lucy24

4:18 am on Apr 3, 2024 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Question that we may have springboarded right over: Does your site use php in any way?

If you don’t know, the next question would be: Does your site use a CMS?

WinMing

5:05 am on Apr 3, 2024 (gmt 0)



All I know is that we are using Wordpress and the SEO tool called YoastSEO.

phranque

6:24 am on Apr 3, 2024 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



To be honest, your responses don't make sense to me because I'm not knowledgeable with codes or something. Is there an easier way I can understand your thoughts?

...we are using Wordpress...


there is a bug - probably in one of your WordPress plugins.

phranque

6:27 am on Apr 3, 2024 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Does your site use php in any way?
...
Does your site use a CMS?

...we are using Wordpress...

fyi the site uses PHP if it is using WordPress, which is a CMS.

phranque

6:38 am on Apr 3, 2024 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



It is not a real error, it looks like it was caused by an error between the tool you were using and the settings of your site or host.

I'm guessing somewhere on the site there is a page which is served a document containing the following string:
<a href="<?php echo site_url();?>"

that PHP code string is not a valid relative URL and obviously if requested should have returned a 404.
that code string should have never been sent by the server in the document since it should have been processed by the PHP interpreter and presumably replaced by a non-404 URL.

logan2914

11:03 am on Apr 3, 2024 (gmt 0)

Top Contributors Of The Month



Hello to the group. we have a number of URLs that have the /1000 trailing that return a 404. G has said that it is spam, but I am trying to find when/if they will be removed or di I simply set up redirects?

not2easy

11:13 am on Apr 3, 2024 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



a lot of 404 errors when I site audited our website using Semrush
I've never used Semrush to find 404s but I'd suspect the error is in Semrush rather than the site because of that "echo site_url()" bit. You could check for errors in your logs or in GSC.

lucy24

4:19 pm on Apr 3, 2024 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



OP, still with us? This is where you need to check your site's access logs. Not analytics, not the analog stats provided by your host, but the raw logs. If you've never done this before and it looks scary, we can walk you through it, though it's better to ask in the Apache subforum.

What we need to know is whether that <?php business was a request sent to your server--which will be visible in logs--or only a response received by the Semrush tool.* Some entities, notably Google, will send in requests that are supposed to yield a 404 response.


* Sorry, semrush, not trying to insult you; it just came out that way.

WinMing

4:44 am on Apr 4, 2024 (gmt 0)



When I checked Google Search Console (GSC), there were 404 errors on our "All Known Pages". However, there were no 404 errors on "All Submitted Pages". I also found "<a href="<?php echo site_url();?>" on our Home Page Template Page Template (page-templates/home_page.php) under Theme File Editor.

What will I do? I appreciate your responses every one.

WinMing

4:48 am on Apr 4, 2024 (gmt 0)



I also found this "<a href="<?php echo site_url();?>" on our Home Page Template Page Template (css/home_page.php).

not2easy

11:52 am on Apr 4, 2024 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



It is normal and common to have a link to the home page on each page, which it appears is the purpose of that code. The
<a href="<?php echo site_url();?>
is not complete as posted, it needs a closing html bracket to function, a
">
to complete the html of the link. It is not visible on a rendered page, not visible to visitors because it is replaced when the page is viewed, by the URL of your site if the html is complete. PHP is processed server-side so it is only visible to you in your template (usually a text file). When a page is rendered in a browser, the PHP code is not visible to visitors. If it is visible, there is an error in your code. Typically, there is an anchor image or text after the URL so the complete code should be something like
<a href="<?php echo site_url();?>"> <img="/logo.png" alt="Home"></a>
that goes with the php echo code string.

You could replace that
<a href="<?php echo site_url();?>
with
<a href="https://example.com">
using your homepage URL if you want to remove it - but if it works as expected for you, no reason to change it. If it does what it is supposed to do, then it is not an error, it is an anomaly in the tool you are using.

You will find it helpful to take time to learn the basics of html when using a template for pages, so you can correct errors that might affect what visitors see.