I have 4 URLs that I would like to redirect to my main page. They are all just common misspellings and I want to have my bases covered so that users can access the site even if they have a letter off. How would I go about doing this with Google App Engine?
I would imagine that I need a python handler to do the redirects but what would this look like? Any resources or examples would be great.
To 301 Redirect a Single Page:html with the file name of the page you want to be redirected. If the file is not in the top-level of the directory, then include the file path in front of the /old-file. html. Replace http://www.domain.com/new-file.html with the URL you want the page redirected to.
If they are, you'll want to redirect (301) that page to another relevant resource on your website. Redirecting 404 pages to somewhere relevant is key. Google treats irrelevant 301 redirects as soft 404's, so there's no real advantage of redirecting unless you're doing so to a similar and relevant page.
Fix Any Broken Redirects Access your website sitemap. Download a list of your URLS. Filter the list for any 301 status codes. Bring back the pages that no longer exist or update the URL to reflect the correct page it should be redirected to.
You can simply use the self.redirect()
and your request will be handled correctly.
class PageHandler(webapp.RequestHandler):
def get(self):
self.redirect('/home/', permanent=True)
You can also set a custom status using the self.response.set_status(301)
. I would suggest you reading more in the docs: Redirects, Headers and Status Codes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With