Set header 410 to parameter can remove index from serp? - seo

i need to set a 410 for pages that contains parameter stats with "?apple".
I try this code :<?php if (strpos($_SERVER['REQUEST_URI'], '?apple') !== false) { header("HTTP/1.0 410 Gone"); exit; } ?>
i have some page link like : webiste.com/?apple , website.com/?apple-fruit
IF i use this code, the homepage will remove from Google ?
Remove only the page with parameters, not the root.

If this is only a temporary problem
You can remove the URLs directly in Google Search Console by following the steps here: https://search.google.com/search-console/removals?resource_id=sc-domain%3Awebsite.com (replace "website.com" with your actual website)
You need to have the website registered in GSC for this to work.
If you don't have access to GSC
I advise you to use canonical URLs instead, this is common practice to make sure Google does not index canonical URLs such as "/?apple" parameters.
The simple fix for this would be to include this simple line in the of each page pointing to itself:
eg. https://website.com/ gets:
<link rel="canonical" href="https://website.com/" />
and https://website.com/another-page/ gets:
<link rel="canonical" href="https://website.com/another-page/" />
this will prevent Google from putting the parameter URLs in the index.

Related

Filter Google Custom Search for pages that contain a specific metatag

I have been trying to filter my google custom searches to pages that specifically contain a meta tag structured as ilustrated below:
<meta data-rh="true" id="meta-og-image" property="og:image" content="https://xxx.jpg"/>
When I get the JSON from GCS I can see the metatag as:
"metatags": [
{
"og:image": "xxx.jpg",
"theme-color": "#fff",...
is it possible to craft a GET command informing in the URL that only pages with that specific meta tag should be part of the results?
As google only returns 10 items per CGS request and the total numer of items found is much bigger than 1000, I need to filter the search itself instead of crawling through results.
CouldĀ“nt get it to work until now.
Thanks for the support!
A query like more:pagemap:metatags:og_image will return pages that that have an og:image metatag
Learn more: https://developers.google.com/custom-search/docs/structured_search

Google Custom Search Engine - Edit the URLs in SERP

Good evening, I'm working with Google Custom Search Engine: https://cse.google.it/cse/ and I need to add, only for some URLs (in total 10 URLs) a parameter at the end of each search results URL. For example: if the domain is www.dominio-test.com then the URL to show is www.dominio-test.com/123456 the CSE searches on the web without restriction.
The code I use is the following:
<script async src = "https://cse.google.com/cse.js cx=014431187084467459449:v2cmjgvgjr0"> </script>
<div class = "gcse-search"> </div>
I thought of proceeding with reading the DOM with getElementsByClassName (), extracting the content and adding it to a variable, at this point add the if / else / replace controls and output again.
But I don't know how to proceed, can you please support me?
Thanks and good job
Search Element callbacks might work for you: https://developers.google.com/custom-search/docs/element#callbacks

How to make seo url for Yii $_GET method using url manager?

I'm working on a site on local server. I have made a form to search country,state and city. After getting the results I see the URL formatted as URL
I want to make this URL as URL
So here I want to know about URL manager rules so I can make it as I want.
Simply add this rule in your url-manager
"site/searchme/<country>/<state>/<city>" => "site/searchme"
Now, you need to have an action with this signature:
public function actionSearchme($country, $state, $city)
You can access $country, $state, $city from url inside this action. For example if your url be like http://localhost/yii_1/site/searchme/UnitedStates/Washington/NewYork, $country will equal "UnitedStates" and so on.

Twitter/Facebook Like URLs ( Pages, UserNames and About Page ) htaccess

Okay, Here are three Facebook URLs:
http://facebook.com/about [A Facebook Page]
http://facebook.com/zuck [Zuckerberg's Profile]
http://facebook.com/like [About Facebook Like Button]
If I have two pages:
http://example.com/user.php?u=[username]
http://example.com/page.php?p=[pagename]
I have successfully rewritten the user.php as http://example.com/[username] but after that when I use the same code for page, and try to access a page like http://example.com/[pagename], a userpage (404 page, because no user with that name exists but a page does) appears. So, What should I do to remove this conflict.
NOTE: I don't want to use URLs like http://example.com/user/Username and http://example.com/page/PageName. Please Help.
You need to rewrite all urls to a separate php file that detects whether the parameter is a username, or page name. The php should look something like this:
$name = $_GET['name']
if( userNameExists($name) )
include('user.php');
else if ( pageNameExists($name) )
include('page.php');
else
include('404page.php');
You need to implement userNameExists() and pageNameExists() off course.

Apache friendly urls

I've got a small CMS system written in PHP and running on Apache. The format of the URLs this CMS system uses/generates is:
/display.php?PageID=xxx where xxx is just some integer number. As you can see, those URLs are not very friendly, neither for users nor search engines.
I believe that using mod_rewrite (or something like that) and .htaccess files I should be able to configure Apache for URL-rewriting. I have searched for information about this before but I did not find any easy method to do this, it always involved messing with regular expressions, which I'm not very familiar with.
Since the website in question is really simple and small, just 5-10 different pages, I would really like to be able to just hard-code the configuration, without any special rules or regexps.
I'd just like to map a friendly URL to an actual URL, perhaps like this:
/about = /display.php?PageID=44
/products = /display.php?PageID=34
etc.
Is it possible to configure the mod_rewrite plugin in a basic way like this?
Could someone explain the easiest method to do this? Explain it to me as if I was a child :-)
Thanks in advance!
well putting something like
RewriteEngine on
RewriteRule ^about$ ./display.php?PageID=44
RewriteRule ^products$ ./display.php?PageID=34
in your .htaccess-file shouldn't be the big deal I think...
URL Rewriting for Beginners is my favorite intro article to this, it should cover what you're looking for. In fact, the first actual example where you write a .htaccess file is almost identical to what you want.
Another way is filter by a dynamic php file with a mapping for pages or a routing strategy like frameworks like drupal code igniter ....
and your URL will be like
my-pages/about.html -> display.php?PageID=44
my-pages/products.html -> display.php?PageID=34
and so on
Here a suggestion for .htaccess file and the filter the action with this strategy
--- .htaccess file ----
*RewriteEngine on
RewriteRule ^my-pages/(.).html$ MY-URL.php [QSA,L,E]
---------------- MY-URL.php ---------
<?php
$PREFIX = 'my-pages/'; //--- not used
$mapping=array(
'about' => 44,
'products' => 34
);
$pathinfo= pathinfo( $_SERVER['REQUEST_URI'] );
/* $pathinfo['dirname'] -> my-pages
$pathinfo['basename'] -> ???.html
$pathinfo['extension']-> .html
*/
$page = substr( $pathinfo['basename'] ,0,-5);
if( isset( $mapping[$page] ){
// ---- redirect or include
YUOR CODE HERE
}
else {
//--- error 404
YUOR CODE HERE
}
?>