Skip to main content

Direct search engines not to index *.herokuapp.com URLs.

Project description

Django app for Heroku users designed to hide your *.herokuapp.com from search engine results.

Use case

You want to develop a website called artisanalraisinbeer.com using Django deployed on Heroku. You write a little bit of Django code and create a new Heroku app called artisanalraisinbeer to deploy to.

While developing, you can visit your site by going to this URL: http://artisanalraisinbeer.herokuapp.com

Eventually, you finish the first version of your website, buy the domain name artisanalraisinbeer.com, and set everything up so that you can view the site just by going to the following URL: http://www.artisanalraisinbeer.com

You can still visit http://artisanalraisinbeer.herokuapp.com, which is fine—but there’s one problem: you want your main site to show up in search results, not your .herokuapp.com site.

How it works

This app goes about this two ways: robots.txt and the X-Robots-Tag. Why both? To be double-plus sure… :eyes:

If herokuapp seems to be in the originating host of the user request, then we do two things:

  • Put the following in robots.txt:

    User-agent: *
    Disallow: /
  • Set X-Robots-Tag in our response header to noindex, nofollow.

For search engines that respect these settings, they should start to ignore these sites in future crawls.

Quick start

  1. Add 'hide_herokuapp' to your INSTALLED_APPS setting.

  2. Add the HideHerokuappFromRobotsMiddleware middleware to your MIDDLEWARE_CLASSES like this:

    MIDDLEWARE_CLASSES = (
        ...
        'hide_herokuapp.middleware.HideHerokuappFromRobotsMiddleware',
    )
  3. Include the hide_herokuapp URLs in your project’s urls.py like this:

    urlpatterns = [
       ...
       url(r'^', include('hide_herokuapp.urls')),
       ...
    ]

    alternatively, you may hook up the view directly:

    from hide_herokuapp.views import herokuapp_robots_view
    
    urlpatterns = [
      ...
      url(r'^robots\.txt$', herokuapp_robots_view),
      ...
    ]

Contribute

PyPI (Downloads)

https://pypi.python.org/pypi/django-hide-herokuapp

Official repository

https://github.com/isms/django-hide-herokuapp

Issue tracker

https://github.com/isms/django-hide-herokuapp/issues

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-hide-herokuapp-0.2.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_hide_herokuapp-0.2-py2-none-any.whl (6.6 kB view details)

Uploaded Python 2

File details

Details for the file django-hide-herokuapp-0.2.tar.gz.

File metadata

File hashes

Hashes for django-hide-herokuapp-0.2.tar.gz
Algorithm Hash digest
SHA256 c1c80820d9f6a2e32f121bc5a5de8581c88e978ac49eae8b230b266238a5d9ee
MD5 9fb20f0bb4a20b2e0971a7e4686146bb
BLAKE2b-256 d6c2d97d8b414b07fb2131006211afdf1a886b59cea4822e4189b712dcb6478d

See more details on using hashes here.

File details

Details for the file django_hide_herokuapp-0.2-py2-none-any.whl.

File metadata

File hashes

Hashes for django_hide_herokuapp-0.2-py2-none-any.whl
Algorithm Hash digest
SHA256 24ebaae53b298e4fd88f71dc4d56fe92b854d43ab9fa2851159e867cb35140bb
MD5 4ddc910867588ac0c284e7040fcb7803
BLAKE2b-256 cdd4cc8a269883f161df54b382c3198c4adac062360de6899a045990aaf27058

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page