I have a website where I am splitting my traffic into two user groups “learners” and “instructors”. I hold their user group in a session variable and direct them to the relevant section of their site.
I am having problems with search engines not indexing the site due to them not having the user_type cookie set. Is there a way I can allow the search engine crawler access to both sections of the site (at the moment it gets stuck in an loop from the user_type selection page to the homepage).
I would also ideally like to be able to allow the crawler access to the member-only resources as there will be content that learner drivers will be able to access that I would prefer was only accessible once logged in.
The code checking the session variable user_type is below and is called on every page (hence why nothing is getting crawled)
if($check_exists==TRUE) {
$this->session->set_userdata('referrer', current_url());
if (strlen($this->session->userdata('user_type'))==0) {
redirect('/user_type/');
}
} else if($check_exists==FALSE) {
if (strlen($this->session->userdata('user_type'))>0) {
redirect('/home/');
}
}
The concept you are using to handle both user types (learner and teacher) is wrong from a SEO perspective. In most cases, you should never have to different content sharing a single URL.
In your case, http://www.road2driving.co.uk/home redirects to http://www.road2driving.co.uk/user_type if no cookie is found. A web crawler will ignore your cookie, and will be caught in a loop. If you want to index both pages, you need to drop the cookie based navigation and create 2 separate sections of your site.
http://www.road2driving.co.uk/home should be your current http://www.road2driving.co.uk/user_type page. Meaning that /home will display 2 links for the learner and teacher sections.
Then create a
learnsection and ateachsection, using a sub-folder for example. You will have:That way all sections of your site be accessible by a crawler.