SEO HTML status 301 on files? - php

Good morning.
Currently trudging through SEO part of a website and i'm using a checklist found on http://www.clickminded.com/seo-checklist/ found parts of to be very helpful.
I have gotten to a part which suggested using Scream Frog SEO which has flagged up quite a significant amount of 301 redirects on images/css/js and even links to other parts of my website.
example of this would be :
Address : http://c-elec.co.uk/welcome/gourmet
Content : text/html
Status code : 301
Status : Permanently moved
Every 301 has the same error and content type even if its an image,js file or css always having their redirect URI has the same as their original address.
I am not sure if this is a problem with how my project is structure or a server issue but other sites i've checked on the server have no 301 when scanned. I'm using php/codeigniter with foundation 5 on a NGINX server.
Thanks for any feedback

It seems, that some of your resources are included using http://www.example.tld.
These requests are redirected to http://example.tld automatically, maybe by some rewrite rule or whatever.
So this request: http://www.c-elec.co.uk/js/app.js is redirected to http://c-elec.co.uk/js/app.js
You need to find out where this redirect is done or include your resources with http://example.tld.
BTW: You are including JS code after the closing HEAD and after the closing BODY tag.

Related

404 page redirects and SEO

I hope this is OK to ask here. I am almost ready to upload a new theme to my blog. Which after some serious consideration and research in SEO I have decided to restructure some of the pages, their child pages and to remove some of the categories.
Unfortunately this will result in various 404 results which will be bad for my site.
What I want to do is this:
On the 404 page, before it loads get last parameter of url, so for example: example.com/parent/child-page-name/
Then perform a check in wordpress using get_page_by_title().
If the page exists get the page permalink then use php header location to send 301 redirect to the new page.
if not, display 404 page with search options etc..
Is this a good way to handle this? is 301 the correct redirect?
To answer your redirect question, yes the 301 redirect is the correct one to use as it passes on the link equity from the last page.
Rather than using PHP to automatically solve your 404 problem when the new blog is launched, I'd crawl your website first and manually redirect all the old links to the new ones. It's tedious, but it will make sure nothing slips through the cracks that an automated process may otherwise miss.
A good way to do this is to crawl your site as it is at the moment, put all the links into a spreadsheet and put the new urls into the next column. From there you can concatenate the urls into a rewrite rule for the .htaccess file.
To show you what I mean, I have set up a basic sheet you can use to help you out.
https://docs.google.com/spreadsheets/d/1htHq0oeATsfrFJpAxKg0_e5dJqSmJ_idrrH-tudkuq4/edit?usp=sharing
Source: Past experience, Commercial SEO Technician for 2 years

How to delete broken/dead links in Joomla 1.5?

I'm working on an old project based on Joomla 1.5. Most of its code was written in core php but it does have SEO URLs. I'm required remove dead links (about 2000 URLs) from the site as it is lowering our organic reach.
When I opened each of them, they showed me the 404 Error page of the site. I couldn't figure out what was wrong with that. After all, that's why we have 404 pages, right? .. to display errors when a link is not found over our server, right?
I tried cleaning up Server's Cache and even purging expired cache after reading some tuts. Now that it doesn't seem to help, I'm not sure what to do! So, any helps?
Btw, site is at www.parentune.com
and an example dead link is: http://www.parentune.com/parenting-blog/category/Adoption/latest
You don't have something to remove as it doesn't exist in your site.
You have to create 301 redirects for old url to new to help search engine crawl your updated content.
A 301 redirect example is:
Redirect 301 /oldpage.html /newpage.html
Good Luck!
As I didn't have any new URLs to redirect those old URLs to, but had the list of those reported URLs in an excel file, so what I did is I read the Excel file in an array and matched if $_SERVER['REQUEST_URI'] was in that array (obviously, all the URLs in that array have to be relative to index page). If the URL was found in the array, I simply redirected the page to homepage.
I also cross checked then on brokenlinkcheck.com and then it didn't report those URLs again as 404 URLs. So, seems like the approach fitted as solution! :D

Html - PHP - Robots

I am just looking for a bit of advice / feedback, I was thinking about setting up and opencart behind an HTML site (shop) that gets ranked well in Google.
The index.html site appears instead of the index.php page by default on the web server (I have tested it).
I was hoping I could construct the site in maintenance mode on the domain, then just delete the html site leaving the (live) opencart site once finished (about 2 weeks).
Just worried in case this may effect ranking.
In the robot.txt file put:
User-agent: *
User-agent: Googlebot
Disallow: /index.php
I would also put in the index.php page (opencart) header:
<meta name="robots" content="nofollow">
<meta name="googlebot" content="noindex, noarchive">
I don't want Google to cache the "website under maintenance" opencart index.php page. It could take a month or so to refresh it.
Obviously I would remove/change the Disallow robot.txt and meta tag etc commands once live and html site files deleted.
I would like to know if any one has tried it or if it will work? Effect google ranking etc?
Is it just a Bad idea? Any feedback would be appreciated.
Many Thanks
I assume you're using LAMP for your website (Linux, Apache, MySQL, PHP)
1) Apache has option to set default page, set it to index.php instead of index.html
2) You may either use re-write rule in .htaccess file (read more here. If your hosting provider doesn't give permission to .htaccess, there's a workaround!In index.php you may include this snippet at the top:
<?php
if($_SERVER['REQUEST_URI'] == '/index.php'){
header("HTTP/1.1 301 Moved Permanently");
header("Location: /");
die();
}
?>
So even if user opens up http://www.domain.com/index.php,
he'll get redirected to http://www.domain.com/
(Eg: My site http://theypi.net/index.php goes to http://theypi.net/)
I've also set similar redirect for http://www.theypi.net to redirect to http://theypi.net
Choosing between one of the two options (with or without www) helps improve ranking as well)
To your question
I would like to know if any one has tried it or if it will work? Effect google ranking etc?
Shorter URL: This is part of URL hygiene which is meant for SEO improvement
If homepage opens just through domain name (without index.php) then your CTR (Click Through Rate) impact in search results is higher.
I would suggest not to use robot blocking mechanism unless above steps aren't feasible for you.
Hope it helps, Thanks!
Edit:
And if you don't even have permission to set homepage as index.php. You may do one of following:
1. create index.html and put php code. If WebServer understands php, put redirect logic as above.
2. else, put JavaScript redirect (not a recommended way)
<script language=”JavaScript”> self.location=”index.php”; </script>

Keep old website (HTML files) on webserver but disallow search agents to index them

I’ve just finished a website for a client who is going to replace their old (very old, HTML hard-coded website). The problem is that they (for now) want to save their old website and all the files on the webserver in the original position. This does not create any issues with the new website which is made in PHP and Wordpress but it makes a big deal when Google (and others) are dropping by with their search robots and indexing.
When doing a Google search it still finds the old HTML files. Is there any way that I could “keep” the old HTML files on the web server but make sure that for the first no robots are going to index them and if anyone is trying to navigate to an HTML page, e.g. http://www.clientdomain.com/old_index_file.html, they are getting redirect? I think the last part might be able to be done in .htaccess but I haven’t found anything useful searching for it.
The first question about not allowing robots and agents to index HTML files, I’ve tried to put these two lines in my robots.txt file
Disallow: /*.html$
Disallow: /*.htm$
But I’m unsure if it will work?
I might deal with this in a completely wrong way but I’ve never tried that a client has requested to keep the old website on same server and in original location before.
Thanks,
- Mestika
<?php
$redirectlink = ‘http://www.puttheredirectedwebpageurlhere.com‘;
//do not edit below here
header (‘HTTP/1.1 301 Moved Permanently’);
header(‘Location: ‘.$redirectlink);
exit;
?>
This code will use a 301 redirect the page to the URL that you desire. The filename of this .php should be the URL slug of the page you want to redirect.
301 Redirect
A 301 redirect, or also known as a permanent redirect, should be put in place to permanently redirect a page. The word ‘permanent’ is there to imply that ALL qualities of the redirected page will be passed on to the detour page.
That includes:
PageRank
MozRank
Page Authority
Traffic Value
A 301 redirect is implemented if the change you want to make is, well… permanent. The detour page now embodies the redirected page as if it was the former. A complete takeover.
The old page will be removed from Google’s index and the new one will replace it.
Or you can do it in your htaccess like shown by the above poster.
There's probably a lot of ways to handle this, assuming you have a clear mapping of pages from the old template to the new one, you could detect the Google bot in your old template (see [1]) and do a 301 redirect (see [2] for example) to the new template.
List item
[1] how to detect search engine bots with php?
List item
[2] How to implement 303 redirect?
Will take some work, but sounds like you'll need to crack open your htaccess file and start adding 301 redirects from the old content to the new.
RewriteCond %{REQUEST_URI} ^/oldpage.html
RewriteRule . http://www.domainname.com/pathto/newcontentinwp/ [R=301,L]
Rinse and repeat
This is definitely something mod_rewrite can help with. Converting your posted robots.txt to a simple rewrite:
RewriteEngine on
RewriteRule /.*\.html /index\.php [R]
The [R] flag signifies an explicit redirect. I would recommend seeing http://httpd.apache.org/docs/2.4/rewrite/remapping.html for more information. You can also forbid direct access with the [F] flag.

Migrating an existing PHP site to use URL re-writing (Pretty URL's)

I currently have a community site that I run that is made up of 15 or so php pages. It is not currently very dynamic, only using php for includes/templates.
Currently no content is generated via a query string. The pages do not follow a standard naming convention and there are many inbound links.
I am looking to expand the site (and start using query strings to build pages) but before I do this I want to change over to use pretty url’s. With this in mind I have a few questions though.
1) Is it best to point all requests to a url rewriting page catch any request to .php pages first and pass them through to keep existing links then a giant case statement for each of the 15 pages finally the rewrite the url's of new pages as these will follow a set format?
2) How can I prevent duplicates in google after I have updated my sitemap.xml or will it remove the old pages?
Thanks
1) I'd redirect using apache's URL rewrite, and leave that static. It'll avoid the mess of having those 15 files you already have in your site.
I hope I have not misunderstood your question and this helps.
2) Edit robots.txt in the root of your website to tell google (and most others) what it should index, and what it shouldn't:
Google's info on the subject: http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=40360
Wikipedia: http://en.wikipedia.org/wiki/Robots_exclusion_standard
More info: http://www.robotstxt.org/
You should use a 301 permanent redirect from the old pages to the new URLs. This will redirect users that follow links from the old to the new and Google will pass the PageRank you have accumulated on the old pages to the new one. You might also look at using Googles new canonical tag on the old pages to ensure they transfer authority to the new page.
http://googlewebmastercentral.blogspot.com/2009/02/specify-your-canonical.html
In .htaccess, you want a bunch of
redirect 301 /old/old.htm http://www.you.com/new.htm
Regardless how its implemented, make sure any redirects use HTTP status 301, not the default (in may systems) of 302.
302 = Moved
301 = Moved permanently.
Using 301 helps google replace the old with the new URL, and should help pagerank etc carry over as well.

Categories