Disallow search link on a website with robots txt - robots.txt

I want to disallow the search link on my site in the robots.txt.
After I click the search submit button, my URL will look like:
example.com/searching?k=something
How can I write this URL address into my robots.txt file?
My robots.txt file looks like this:
User-agent: *
Disallow: /admin_folder
Sitemap: https://www.domain-address.com/sitemap.xml
Host: www.domain-address.hu
function search_k()
{
if($.trim($('#country_id').val()) != "" )
{
//document.location = http_host+'/kereses.php?k='+$('#country_id').val();
var KeyWord = encodeURIComponent($('#country_id').val()).replace(/%20/g, '+');
document.location = http_host+'/searching?k='+KeyWord;
}
return false;
}

If you want to disallow compliant robots from crawling all URLs on your site starting with /searching, then just add another exclusion to your robots.txt file after your other Disallow commands:
Disallow: /searching
For more details on the format, read more about the de-facto standard that most crawlers adhere to.

Related

how to make this nginx location redirect not case sensitive

my situation:
domain.com is a WordPress site (and WP works fine). its installed at the root.
I also created/add a sub folder: domain.com/subfolder
that has an index.php page in it, like so:
domain.com/subfolder/index.php
I need any URL entered into browser to redirect to subfolder index.php page.
I have this nginx location, but it ONLY works if you type in case sensitive subfolder or subfolder/, I need non-sensitive:
location /subfolder {
return 301 http://domain.com/subfolder/index.php;
}
location /subfolder/ {
return 301 http://domain.com/subfolder/index.php;
}
SO basically, if user types anything except subfolder or subfolder/, let WP take care of the url. otherwise, redirect it.
I've tried ~ ^ *, but can't get it to work right.
what am i doing wrong? :)
thanks!
PS. if you see something else that I should be doing, please let me know -- i'm new to nginx
Try this:
location ~* /subfolder/ {
return 301 http://domain.com/subfolder/index.php;
}
The tilde and asterisks ensure that this location will be matched case insensitive.

Nginx redirect all contents of a subdirectory to another subdirectory

Let say that I have a url like this:
http://www.example.com/admin/admin.php?fail=1
how can I rewrite the url to be
http://www.example.com/another/subdirectory/admin.php?fail=1
Thank you
Update: this is what I've tried so far, but it will not redirect admin.php?fail=1
location /admin/ {
rewrite ^/admin/(.*)$
/another/subdirectory/$1 redirect;
}
I rather use return 301 for redirections and use rewrite only if I want to display something like a nice url.
Please try the following
location ~ ^/admin/(.*) {
return 301 /another/subdirectory/$1 ;
}

How can I redirect an address starting with #!

I have a new wordpress site instead of my old Wix one.
in the old one there were page addresses like http://example.com/#!contact/ct07/ in the new one this page resides under http://example.com/contact
I've tried 3 redirections plugins but none works (Redirection, redirection editor, quick 301 redirect).
I have no access to the .htaccess file
On redirection it seems like the engine does not see the URL.
Any manageable idea besides JS ? I don't want to miss google juice
Browsers don't send the part after # to the server, so the server don't know about this part and won't be able to do the redirect.
So you have to do the redirection in javascript:
if (/^#contact\//.test(document.location.hash)) {
document.location = '/contact';
}
For SEO purpose, you may want to handle the _escaped_fragment_ parameter too
I had this problem a few weeks ago.
PHP does not get anything after hash tag, so it is not possible to parse request url and get hash. But JavaScript can.
Below you find my solution for WordPress redirects by hashtag #! :
(You should put this code in functions.php of your active theme):
function themee_hash_redirects() {
?>
<script type="text/javascript">
function themee_hashtag_redirect( hashtag, url) {
var locationHash = document.location.hash;
if ( locationHash.match(/#!/img) ) {
if ( hashtag == locationHash ) {
document.location.href = url;
}
}
}
// Examples how to use themee_hashtag_redirect
themee_hashtag_redirect('#!contact', '/qqq/');
themee_hashtag_redirect('#!zzz', '/aaa/');
</script>
<?php
}
add_action('wp_footer', 'themee_hash_redirects');

How to delete facebook parameters that puts the url's shared on your wall in codeigniter links

When I share a link http://www.totalrunning.com/results/misFotos/TTRCAR1346364033/283 (Codeigniter Url's) on my Facebook wall appears fine but when clicking the resulting URL is: http://www.totalrunning.com/results/misFotos/TTRCAR1346364033/283?fb_action_ids=441641579216005&fb_action_types=og.likes&fb_source=aggregation&fb_aggregation_id=288381481237582
fb_action_ids added among other parameters this causes the url not resolving correctly
That I can do to make facebook not put those parameters in my url or like handling with Codeigniter ???
Thanks
Enabling Query Strings
In some cases you might prefer to use query strings URLs:
index.php?c=products&m=view&id=345
CodeIgniter optionally supports this capability, which can be enabled in your application/config.php file. If you open your config file you'll see these items:
$config['enable_query_strings'] = FALSE;
$config['controller_trigger'] = 'c';
$config['function_trigger'] = 'm';
If you change enable_query_strings to TRUE this feature will become active. Your controllers and functions will then be accessible using the "trigger" words you've set to invoke your controllers and methods:
index.php?c=controller&m=method
You can read more at the Code Ignitor user-guide here: http://codeigniter.com/user_guide/general/urls.html
The solution I found was through the same file using Codeigniter .htaccess to hide the index.php
Above this htaccess put the following:
# -----------------
RewriteCond% {QUERY_STRING} ^ fb_action_ids = (. *) $ [NC]
RewriteRule ^ (. *) $ / $ 1? [R = 301, L]
# -----------------
with this code you tell the server that elime the query string of the url but only when he comes fb_action_ids or any parameter you choose not prevent the proper functioning of query strings in CodeIgniter
With this you can preserves the beautiful codeigniter urls and facebook links resolved correctly!
Important: Put it up to avoid file overwrite functionality to hide the index.php
I wouldn't recommend this method. Just add a slash after your final parameter and it will work fine. It will ignore all those facebook extras

Redirect user to mobile site and back in typo3 with typoscript

I have found that if I use the below typoscript I can redirect my users to the mobile version of the site which has its own tree in the backend of my typo3 site.
[useragent = *iPhone*]||[useragent = *iPod*]||[useragent = *Android*]
config.additionalHeaders = Location: http://m.example.com/
[end]
It is a simplified version of the site however so I want to have a return to full website link. But due to my above typoscript redirecting users to the m domain i can't get back to www.example.com.
Does anyone have any typoscript suggestions here?
You need an additional parameter in your link back which you can use to turn off the redirection.
Try something like this:
# check for mobile browser
[useragent = *iPhone*]||[useragent = *iPod*]||[useragent = *Android*]
config.additionalHeaders = Location: http://m.example.com/
[global]
# undo mobile redirect if mobile param is set
[globalVar = GP:nomobileredirect > 0]
config.additionalHeaders =
[global]
and redirect to http://www.example.com/?nomobileredirect=1 on your link back.
To keep a nomobileredirect-value in all generated links, add nomobileredirect to your linkVars, e.g.
config.linkVars = nomobileredirect,L
You can use another condition on a GET parameter and override the config.additionalHeaders later. Remember, TS is not a scripting language, but rather a static configuration. The last statement always wins and rendering starts only once all TS has been parsed.
You can also try to extend the above condition by an additional exclude of a GET parameter.