Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
My rewrite rules:
RewriteRule ^articles/([a-z]+)/([0-9]+)/?$ /index.php?page=articles&cat=$1&id=$2 [L]
RewriteRule ^articles/([a-z]+)/?$ /index.php?page=articles&cat=$1 [L]
RewriteRule ^([a-z]+)/?$ /index.php?page=$1 [L]
So, in index.php file, i check for existence of page. If it is found, that page is echoed. Otherwise, what to do ?
Send a redirect to home page ?
Send 404 page not found response using header() ?
Echo a message like "Page Not Found" ?
Which one is good? I want to know search engine friendly option among these.
You should definitely have a header() which returns the proper 404 error code. This will ensure that google does not index your error page. Serving a standard page with a message without the 404 code is called a soft 404 error, and is discouraged by the standards (and by google).
See here: http://support.google.com/webmasters/bin/answer.py?hl=en&answer=181708
But it is not necessary to show an ugly text-only error to your visitor, or rely on his browser's default error page. Even if you output a 404 code, you can still serve a beautiful page, maybe with a link to your home page, or with relevant resources.
In precedence
Send a 404 page not found response using header() ?(hard 404)
Which is ideal as the page was literally not found.
Echo a message like "Page Not Found" ? (soft 404)
This is fine as you are trying to find the page internally but not exactly ideal.
Do not do a:
Send a redirect to home page ?
As this does not portray any information like,
whether the page was not found.
was there any internal error.
etc.
Go through this: 404 errors soft vs. hard you will get the idea.
Related
I have an issue while google indexed my old URL where it doesn't longer exist, when someone clicked on the old link from Google search, there will shown 500 server error in product page.
My old URL for product page is mydomain.com/item/item-name, which recently I was re-built a new rewrite rules in .htaccess to mydomain.com/product/item-name for SEO wise, I want my old URL at least can redirect to my landing page instead of display an error for the visitor that could build bad impression for my site.
How can I solve this issue?
In your htaccess write this :
RewriteRule ^item/(.*) mydomain.com/product/$1 [L,R=301]
Here all links coming to mydomain.com/item/item-name will be redirected to mydomain.com/product/item-name.
This link provides instructions on how to request Google to remove cached content or wait for Googlebot to reindex, the second part after rewriting .htaccess rules.
http://googlewebmastercentral.blogspot.com.au/2010/04/url-removals-explained-part-ii-removing.html
In the short term you can use an ErrorDocument in Apache to catch the 500. This can point to a PHP script that can redirect to wherever you choose.
However, you should really find out why old URLs are producing a server error in the first place. If content is being removed, they should return a "not found" page together with a 404 response code.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I want to know the advantage of 404 Not Found page. Why should one create a design for that ? Why not just set 404 header and redirect it to the home page with a message something like "What do you want of the URL? Please just walk into the website".
I figured many websites have a special page for the purpose. But why ?
Regards
404 Not Found
The 404 (Not Found) status code indicates that the origin server did not find a current representation for the target resource or is not willing to disclose that one exists. A 404 status code does not indicate whether this lack of representation is temporary or permanent; the 410 (Gone) status code is preferred over 404 if the origin server knows, presumably through some configurable means, that the condition is likely to be permanent.
Hypertext Transfer Protocol (HTTP/1.1), section 6.5.4
404 pages let users know that the page does not exist.
Many people will change the URL manually (for example, /pictures/page/1 to /pictures/page/2). If you redirect the user to the front page it will be confusing to them. What they expected to happen (either go to page 2 or get a "Page not found" error) will not happen; finding themselves on the front page is not useful.
The more important thing, however, is that users should ideally never see 404 pages. When they actually do see one, it should be very clear that the page does not exist. Redirecting them does not tell them that the page does not exist; it tells them that... it is the front page, which it should not be. It is confusing.
Another issue is that search engines may find it odd that a lot of your pages get redirected to your front page. It is not exactly how the internet is supposed to work, so they may actually penalize your website because of it.
If you want your users to have a good experience on your website then your 404 pages should attempt to help them find whatever they were looking for. Some things you can show the user are:
A search box. Google has custom search boxes you can put on your website, which only search your site. If making your own is too complicated then this is a good solution.
If you are able to do something like this, then showing the user content that may be similar to what they are looking for can be useful. Just make sure that it works reasonably well. For example if you cannot find anything similar then don't show random stuff -- it is not helpful.
The newest content on the page. This is especially useful if it is a blog, news site, or some other kind of website that frequently gets new content.
The most popular content. If the user is just browsing to pass the time then popular content may allow them to continue browsing without leaving your website.
A link to or showing a sitemap may also be useful if the website is small enough to summarise on one page.
...and so on. Just try to think of what would be helpful to the user.
A good custom 404 page will help people find the information they're looking for, as well as providing other helpful content and encouraging them to explore your site further.
Moreover if you do not make your own custom page, the server's 404 error will be displayed which would not go by the design of your website. There are also negative elements which would try to access the unauthorized pages, and keeping a check of the same will give a sense of secured website.
What if you go in a departmental store and looking for a soap which
actually is out of stock, but the store keeper just make you to start
again from the section. Isin't the message not available is a
better option? The same goes here
The idea of a 404 page is to tell the user that the file they were looking for wasn't found, or that the link they clicked on was broken.
Say you're running a news site and a user clicks on a link to an article on your site, but the article has been deleted. A 404 page makes it very clear to the user that the article is gone. If you just redirect them to your homepage, they might think a featured article on your page is the one they were linked to, or that they got redirected for no reason. They won't have any reason to think that what they were looking for no longer exists on your server.
So the purpose of a 404 page is to say "Hey, what you were looking for isn't here." If you want to get more fancy, you can even use a 410 error instead, which means "Hey, what you were looking for used to be here, but it's gone now."
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 8 years ago.
Improve this question
I have a well-known domain name and receive something like 5k visitors per day.
But i really want to change my domain and my pages title, a complete renew!
Have some way to do this without losing my page rank and visitors?
For example, now if someone from my country (brazil) search about a tablet my site will appear in first page.
In really, i have 3 sites with one domain.
shop.mydomain.com
forum.mydomain.com
www.mydomain.com (wordpress blog)
If possible i want to change just the shop domain.
A long time ago i read about a changes like that, 301 redirect or something like this that preserves your page rank and google position.
My new domain is exatcly the keywork that my visitors search, probably with this change i will get the first place in searches.
I do not want lose backlinks
Help please?
As Matt Cutts explains, a 301 redirect is the best way to redirect users:
If you need to change the URL of a page as it is shown in search engine results, we recommend that you use a server-side 301 redirect. This is the best way to ensure that users and search engines are directed to the correct page. The 301 status code means that a page has permanently moved to a new location.
This CSS Tricks article explains how to implement a 301 redirect, but essentially:
If you want to use a 301 redirect (which is the quickest, cleanest, and most search engine friendly option) to direct browsers to an entirely new website, place this line in the .htaccess of the old site
Redirect 301 / http://newsite.com/
If you only want to redirect a particular page, place this in the .htaccess of the old site
Redirect 301 /oldpage.html http://www.yoursite.com/newpage.html
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I'm trying to create a blog ..and for every entry I have a template page called entry.php
I create the pages by creating a link from my home page like this
mywebsite.com/entry.php?title=My Title&content=This is my blog
This link is passed to entry.php and a page is generated on the fly based on the link i wrote but search engines wont index these.
Do I really have to create a unique page for every entry I create?
Do sites like youtube have individual pages for every single video or are they generated dynamically like im trying to do. If so how do the videos show up in search results?
Ive heard something called .htaccess or sitemap.xml can be used for this I have no idea what these are though.
Learn about .htaccess
There are a lot of generators for .htaccess and you can use one of them. The best thing to do is, using a .htaccess file, create the paths this way:
mywebsite.com/entry.php?title=My Title&content=This is my blog
Change them to:
mywebsite.com/My Title/This is my blog
And the code for the same is:
RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)\.html$ /entry.php?title=$1&content=$2 [L]
Websites offering generators:
.htaccess redirect
Mod Rewrite Generator
Search Engine Optimization Tools ยป mod_rewrite rewriterule generator
As long as the page is linked to from somewhere, search engines will find the page. It does not matter how the page is generated. A link is a URL, when requesting this URL the browser or any other client (including search engines) receive the page content, period. It works like any other regular page, search engines don't know or care what happens behind the scenes to generate this page.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
In my website I have the following categories url structure:
/category.php?id=6 (id=6 is for internet category)
My SEO friendly url is like:
/category/6/internet/
The problem is it can be accessed in any of those forms, and because of that, I'm getting duplicate content on google.
So, I'm wondering how can I fix that.
Should I disallow on robots.txt any urls with ? on it?
If so, how can I properly set it up?
Should I make a redirection "Permanently Moved" on .htaccess?
If so, how can I properly set it up?
My actual .htaccess for categories is like this:
RewriteRule ^category/([^/]*)/([^/]*)/$ category.php?id=$1&name=$2 [L]
You just need to set the canonical link tag in the head section of your pages
see http://googlewebmastercentral.blogspot.com/2009/02/specify-your-canonical.html
and http://support.google.com/webmasters/bin/answer.py?hl=en&answer=139394
It will look something like
<link rel="canonical" href="http://www.example.com/category/6/internet/"/>
on the category 6 page
You could also do a 301 redirect for the category.php pages in your .htaccess by adding
RewriteRule ^category.php?id=([^&]*)&name=([^&]*) /category/$1/$2/ [R=301,L]
If you didn't want to go the route of rewriterules you could put the following code at the top of config.php:
if(preg_match('/^\/config\.php/', $_SERVER['REQUEST_URI'])){
header("HTTP/1.1 301 Moved Permanently");
header("Location: /category/{$_GET['id']}/{$_GET['name']}");
die();
}
Either way is up to you but I would use the rewriterule option to redirect to my SEO friendly URL If I were you
Or you get rid of the non-SEO url.
always generate SEO url (you should do that anyway for)
in category.php check if $_SERVER['REQUEST_URI'] is the seo one and if not redirect to it
I would suggest using a canonical link in the document head to ensure Google uses the correct URL. Google on Rel Canonical.
It's really easy to implement, just post this into the HEAD section of the page.
<link rel="canonical" href="/your/url"/>
Google treats the canonical link as a 301 redirect, which means you won't have any duplicate content issues. It also means most of the link juice gets passed on (between 90% and 99%). If you used robots.txt or .htaccess , the page that you're blocking off would lose all its SEO value.
Just make sure you do this for every page as it's a page specific rule. Linking to the domain root will effectively mean all your pages are 301 redirecting to the home page.