SEO URL redirect: www - http://www - etc - codeigniter

I am creating a CodeIgniter site. I have an SEO problem to address. The following URLs all point to the same page, although search engines see them all as different urls:
www.yahoo.com
http://www.yahoo.com
http://www.yahoo.com/
Does CodeIgniter have a function that can automatically redirect pages to a single URL?
if not, has anyone written a function that can create a unifying URL for the redirect?
Currently I am redirecting all pages to:
"http://-----.com/" . uri_string();

Use canonical URLs. Basically you tell the search engines that when they pull up that page by any of those URLs that the one you specify as the canonical URL is the one to be considered the "main" URL and shown in their index. The others are then not considered duplicates.
<link rel="canonical" href="http://www.yahoo.com/" />

Related

Need to change hmvc routes in CodeIgniter

I have CodeIgniter HMVC application and I want to change route as per requirement.
Now I have website/product/detail/url, and I want to change it with website/url.
Once I set URL from admin side it will redirect to my route.
This is what I have now:
$route['Products'] = "Products/detail/d101productdatatest(this is url)";
And I want in my url like website/url and it will open same page what I have with website/product/detail/url
From the given library:
https://www.codeigniter.com/userguide3/general/routing.html
routes as above:
$route['controller/function'] ='website/Products/detail/d101productdatatest';
But as per your given question:
you cannot manipulate url using routes
you can map same function with different url using routes
you have to use .htaccess to redirect to specific url after hitting the previous given url.
htaccess example:
Redirect /index.html /new/
Redirect /index.html /default.html
Redirect /private/ http://www.example.com/private/
Redirect /img/logo.gif http://www.example.com/images/logo.gif
Hope this answer helps you out !!
cheers

Google does not index startpage (index.html) of AJAX application correctly but all subpages containing a hashbang (#!)

I followed the google guideline Making AJAX applications crawlable to make my AngularJS Application crawlable for SEO purposes. So I am using #! (hashbang) in my routes config:
$locationProvider.hashPrefix('!');
So my URLs look like this:
http://www.example.com/#!/page1.html
http://www.example.com/#!/page2.html
...
As google replaces the hashbangs (#!) with ?_escaped_fragment_= I redirect the google bots via my .htaccess file to a snapshot of the page:
DirectoryIndex index.html
RewriteEngine On
RewriteCond %{QUERY_STRING} ^_escaped_fragment_=/?(.*)$
RewriteRule ^(.*)$ /snapshot/%1? [NC,L]
So far everything works like a charm. When a bot requests following URL http://www.example.com/#!/page1.html it will replace the hashbang and actually requests http://www.example.com/?_escaped_fragment_=/page1.html which I redirect to the static/prerendered version of the requested page.
So I submitted my sitemap.xml via the Search Console from Google Webmaster Tools. All URLs in my sitemap are indexed correctly by google but not the domain itself. So it means that a page like:
http://www.example.com/#!/page1.html
is indexed correctly and by googling specific content of any of my subpages google finds the correct page. The problem is the start/homepage itself which "naturally" has no hashbang:
http://www.example.com/
The hashbang here is appended (via javascript in my router configuration) when a user visits the site. But it looks that this is not the case for the google bot.
So the crawlers does not "see" the hashbang and hence does not use the static version here which is a big issue because especially here I provide the most important content.
I already tried to rewrite and redirect / via .htaccess to /#!/but this ends up in to many redirects and crashes everything. I also tried to use
<meta name="fragment" content="!">
in the header of the index.html. But this did not help at all.
Does anybody else faced that problem before?

Change URL in address bar but keep on same page

Is it possible to rewrite a url so that the page stays the same and the url itself is chanaged ?
E.G.:
I have a page at www.example.com/sales
I want this url to appear in the address bar as www.example.com/sales_and_repairs
I am NOT trying to redirect a page at www.example.com/sales to ANOTHER page at www.example.com/sales_and_repairs ....There is only ONE page - it is just the URL I am trying to change so that if a person types in www.example.com/sales, they will go to that page but the URL in the Address bar will change to show as www.example.com/sales_and_repairs
Is this possible with rewrite rules ? Anytjhing I have looked up appears to suggest that you have to be redirecting to a second page - but that is not what I want to do - I just want to change the actual URL.
Any advice please ??
If you want to redirect www.example.com/sales_and_repairs to www.example.com/sales permanently you can do it with an .htaccess file.
First of all, you'll have to enable mod_rewrite in apache.
Then add the following to your .htaccess file :
Options +FollowSymlinks
RewriteEngine on
Rewriterule ^http://www\.example\.com/sales_and_repairs$ http://www\.example\.com/sales [R=301,NC,L]
This method allow you to have only one file behind the two urls.
However if you want to modify the url after a user's action, you can do it with the answer given by Sparda above.
Seems you can achieve this with javascript :
location.hash = 'newurl';
But this will add an anchor to the url.
Some earlier features of html5 can do this but are not really supported yet :
history.pushState(data, 'title', 'newurl');

Tidy URL losing relative links

I've been implementing tidy urls and querystrings into my site but can't get querystrings to resolve AND show the page correctly - all links become relative to the 'faux' directory
I'm using
RewriteRule ^services/([0-9]+)/?$ services.php?sv=$1
in .htaccess
so /services/2 becomes /services.php?sv=2
but the resulting page displays incorrectly.
I can only think that it's impossible to use relative links when using tidy urls and querystrings but I can find no mention of this anywhere.
Standard link: http://www.tomatedesign.com/sample-site/services.php?sv=2 as normal with querystring
and finally: http://www.tomatedesign.com/sample-site/services/2 tidy URL with a querystring
The RewriteRule is doing its job, services/1, services/2 and services/3 all get the correct content included on the page just everything else is broken.
actually I just had to include
<base href="/">
in the file to have the page resolve the links appropriately

joomla - SEO settings and mod_rewrite

I'm using Joomla 1.5.14 and I configured SEO as in the following image
Now I need to map a few old URL to the new site
let's say that I need to map htp://mysite/old.html to the new Joomla page
http://mysite/index.php?option=com_content&view=article&id=32&Itemid=70
I added in my .htaccess file the following
RewriteRule ^old\.html$ index.php?option=com_content&view=article&id=32&Itemid=70 #works!!
this works fine, but if I use the SEF URL in .htaccess (let's say the above page can be reached with htp://mysite/contacts.html), I obtain a 404 error
RewriteRule ^old\.html$ contacts.html #this does not work
Now the question:
Is it possible use SEF URLs in RewriteRule? where am I wrong?
thank you in advance
stefano
I think the problem is because Apache rewrites old.html to a page that doesn't actually exist, but rewritten in a different rule.
If you truly want to "rewrite" - in other words, have the page stay as old.html in the browser - then you don't need to do anything.
However to avoid duplicate content it's probably better to do a 301 redirect:
Redirect 301 old.html http://yoursite.com/contact.html
(You may need a forward slash at the front of old.html)

Resources