I'd like to have the search ranking on my root domain to carry through to my blog subdomain. I'm not sure if this makes sense, but I thought perhaps 301 Redirect from mydomain.com/blog to blog.mydomain.com and having a canonical tag linking back to mydomain.com/blog would help.
For example: A user or search engine goes to mydomain.com/blog/my-post, a 301 redirect takes them to blog.mydomain.com/my-post. On that post is the link tag: rel='canonical' href='mydomain.com/blog/post'
Or, a better example would be someone links to blog.mydomain.com/post and that inbound link goodness gets transferred to mydomain.com. I'm not sure if this works in the other direction: i.e. a link to mydomain.com transferring link goodness to blog.mydomain.com
No, this won't work. The 301 redirect will be followed by search engines to determine the "real" canonical URL.
See the Google FAQ:
Can rel="canonical" be a redirect?
Yes, you can specify a URL that redirects as a canonical URL. Google will then process the redirect as usual and try to index it.
However, RFC 6596 discourages to use a permanent redirect:
To better ensure that applications properly handle the canonical link relation, administrators ought to consider the following guidelines:
[…]
Avoid designating the target (canonical) as:
[…]
The source IRI of a permanent redirect (for HTTP, this refers to 300 and 301 response codes defined in Sections 10.3.1 and 10.3.2 of [RFC2616]
What framework/language/CMS are you working with?
I guess you could dynamically add your canonical element
<!-- html from mydomain.com -->
%define_domain% = ( %define_domain% ) ? 'mydomain.com' : 'blog.mydomain.com'
%extra_goodness% = 'blog/my-post'
<meta name="canonical" content="%define_domain% / %extra_goodness%">
Related
I am using AEM. I have configured some vanity URL's with redirect. Ex:
/coaties > /content/geometrixx-outdoors/women/coats/winter-coat.html
Also in the web server, I have made configuration to strip HTML extension so my web-server removes the html extension with another redirect. Now when I hit vanity URL, I will have 2 redirects
/coaties > /content/geometrixx-outdoors/women/coats/winter-coat.html [1st redirect]
/content/geometrixx-outdoors/women/coats/winter-coat.html >
/content/geometrixx-outdoors/women/coats/winter-coat [2nd redirect]
I want to avoid 2 redirects and I dont want to show HTML extension to end users.
/coaties > /content/geometrixx-outdoors/women/coats/winter-coat [only one redirect]
I spent some time on the Sling side with no luck. All I understand is, since Sling will return 403 for all URL's without extension, it always returns URLs with extension. Is this possible at dispatcher or web server side ?
If i understand, you want to strip the .html extension from all the pages of your site.
The solution of #awd will ensure that all the hrefs in your page would be transformed to uris with no extension.
If you want no extension at all in your site, you should use an internal redirect by creating map under /etc/maps, you can find the official documentation here: http://sling.apache.org/documentation/the-sling-engine/mappings-for-resource-resolution.html
Thanks everyone for contributing.
I found the following solution for the problem
I would do the following configurations for webserver
For apache, in httpd.conf
Header edit Location (.*).html$ $1
For iPlanet in obj.conf
<If $srvhdrs{'Location'} =~ "^(.*).html$">
Output fn="set-variable" $srvhdrs{'Location'}="$1"
</If>
This would make sure that html extension would be removed from location header for redirected URL's.
We have a global website and local websites for some countries. Now we need to redirect all local sites to global website in a way that we have each countries main page on global website. We are going to use sub pages of global site. My .htaccess looks like this:
Redirect 301 / http://newdomain.com/uk
Redirect 301 /about-us/ http://newdomain.com/about-us/
Redirect 301 /contact-us/ http://newdomain.com/contact-us/
Its working for home page but not working for sub pages. Instead of redirecting them to "http://newdomain.com/about-us/" it keep redirecting to "http://newdomain.com/ukabout-us/"
What to do?
NEVER USE 301 REDIRECTS
(unless 1) you know what you are doing 2) you know the consequences of what you are doing 3) you have extensively tested the configuration using 302 redirects).
I'm guessing that none of the 3 provisions above have been met in your case.
There is an implicit wildcard on the first path supplied as an argument to Redirect. To force a literal match, use RedirectMatch with anchors (e.g. "^/$"). Make sure you use 302 until you've got it working properly.
BTW getting the 301 redirects out of your browser is difficult - just clearing the cache does not always work.
To achieve a single layer of content delivery security, I'm looking into the possibility of obscuring a resource URL via an .htaccess RewriteRule:
RewriteEngine on
RewriteBase /js/
RewriteRule obscure-alias\.js http://example.com/sensitive.js
It would of course be implemented as:
<script type="text/javascript" src="obscure-alias.js"></script>
Because this is not a 301 redirect, but rather a routing scenario similar to that of many of our frameworks we used today, would it be safe to say that this RewriteRule adequately obfuscates the actual URL where this resource is located, or:
Can the destination URL still be found out via some HTTP header sniffing utility
Might a web browser be able to reveal the "Download URL"
I'm going to pre-answer my own questions by saying no to both since the "internal proxy" is taking place on the server-side and not on the client side if I understand it correctly: http://httpd.apache.org/docs/current/mod/mod_rewrite.html. I just wanted to confirm that when Apache goes to serve the destination URL, that it also isn't passing along information to the user agent what the URL was that it rewrote the original request as.
It depends on how you specify the redirect target.
If your http://example.com/ is running on the same server, there will be an internal redirect that is invisible to the client. From the manual:
Absolute URL
If an absolute URL is specified, mod_rewrite checks to see whether the hostname matches the current host. If it does, the scheme and hostname are stripped out and the resulting path is treated as a URL-path. Otherwise, an external redirect is performed for the given URL. To force an external redirect back to the current host, see the [R] flag below.
if the absolute URL points to a remote domain, a header redirect will be performed. A header redirect is visible to the client and will reveal the sensitive location.
To make sure no external redirect takes place, specify a relative URL like
RewriteRule obscure-alias\.js sensitive.js
Note that the sensitive JS file's URL can still be guessed.
To find out whether a request results in a header redirect, log in onto a terminal (eg. on a Linux server) and do
wget --server-response http://www.example.com
If the first HTTP/.... line (there may be more than one) is something that begins with a 3xx, like
HTTP request sent, awaiting response...
HTTP/1.1 302 Moved Temporarily
you are looking at a header redirect.
Possible using proxy throughput.
See http://httpd.apache.org/docs/2.4/rewrite/proxy.html
Also alluded to here as well: mod_rewrite not working as internal proxy
I have a new website as http://abc.com/case_studies/casstudy20/.
I have an old website as http://xyz.com/clients/home.php?client=myclient
There are loads of case studies and stories under old domain that is xyz.com. Now that I am using abc.com is it possible to replace the URL, so it shows abc.com but access the code from the same old place.
meaning when my users goes to old site instead of xyz.com. It should say http://abc.com/clients/home.php?client=myclient. But runs from the same old xyz.com.
Is it possible to do it using htaccess.
Sort of. You can redirect all the traffic from xyz.com to the proper path on abc.com but this requires you to maintain control of both domains.
If you can, it's actually better to put this in the virtual host config for xyz.com then you don't need a complete configuration at all. Assuming you have permissions it will work in .htaccess as well though.
RedirectMatch ^(.*)$ http://www.abc.com$1
If you can keep control of both domains then you are looking for a http 301 redirect. You can do that by adding the following line to your htaccess file to redirect an entire website. Without control of your original domain it's impossible for your old xyz.com website to be routed to the appropriate server so your htaccess file will never have anything to redirect.
redirect 301 / http://abc.com/
Google has indexed my Heroku app subdomain: myapp.heroku.com
Is it duplicate content?
How should I redirect myapp.heroku.com to mydomain.com?
According to Heroku docs for custom domains, you could do it like so:
class ApplicationController
before_filter :ensure_domain
APP_DOMAIN = 'myapp.mydomain.com'
def ensure_domain
if request.env['HTTP_HOST'] != APP_DOMAIN
# HTTP 301 is a "permanent" redirect
redirect_to "http://#{APP_DOMAIN}", :status => 301
end
end
end
I use this method and it works fine. Note that since the redirect returns a 301 http status (a permanent redirect) your site won't be penalized for duplicate content.
The 301 status is the only point missing in Markus' solution, but I think it is an important one if your concern is with SEO.
Edit: Something that's not on the docs and I forgot to mention - you should exclude the environments you don't want the redirect applied to. You could change the if statement to something like:
if request.env['HTTP_HOST'] != APP_DOMAIN && ENV["RAILS_ENV"] != 'development'
Use the Heroku add-on custom domains:
heroku addons:add custom_domains:basic
heroku domains:add www.myapp.com
heroku domains:add myapp.com
In addition, you have to take some configuration steps at the admin interface of your domain provider. You need a CNAME to proxy.heroku.com and three A-RECORDs to the Heroku IPs. You find this in the Heroku Docs.
Edit to respond to another answer below. You can redirect myapp.com to www.myapp.com in your routes.rb:
constraints(:host => /^communityguides.eu/) do
root :to => redirect("http://www.communityguides.eu")
match '/*path', :to => redirect {|params| "http://www.communityguides.eu/#{params[:path]}"}
end
I suggest using rack-canonical-host to redirect Heroku's subdomain to your custom domain.
rel canonical is one possibility
just put <link rel="canonical" href="http://mydomain.com"/>, <link rel="canonical" href="http://mydomain.com/page"/>, ... on your app pages.
see http://www.google.com/support/webmasters/bin/answer.py?answer=139394
google will treat the URL in the canonical element as the right ressource for that specific page.
The first answer goes part way to solve the problem but introduces a new problem.
If you add www.myapp.com and myapp.com you will then need to take care of redirecting one of these to the other inside your application - so if you choose www.myapp.com as your primary you want to check if the requested URL IS NOT www.myapp.com and redirect the request to www.myapp.com - this will then cover redirects requests coming to myapp.com and myapp.heroku.com correctly. There's an example by Heroku on their docs here.
Also, you need to get rid of the content that Google has already indexed on the Heroku domain. You'll need to use Google WebMaster tools to change the domain to www.myapp.com - it's a relatively simple process once you're logged into webmaster tools
first of all if you do not want your myapp.heroku.com to be indexed simply by adding robot meta tag in your header and give the value to "nofollow".
and for redirection just add another meta tag refresh:
<meta http-equiv="refresh" content="2;url=http://www.heroku.com/">
the content value is in seconds, the example above will direct visiotrs in 2 seconds to your main page.
hope it helps
Use the hide_heroku gem, it uses X-Robots-Tag HTTP headers to prevent search engines from indexing anything under *.herokuapp.com