Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Help with 301 redirect

Featured Replies

Hi, I wonder if anyone can help. I have created a .htaccess file and put the following in it. Then uploaded. But when I input the old url, it shows up and does not redirect to the new url. What have I done wrong? Can anyone advise? Thank you. (the urls are just examples here as I don't want to post my client's site). But the .htm and the .php are the same.Thanks.

 

Redirect 301 /old/old_old.htm /new/http://www.newsite.com/index.php

  • Author

Hi, I wonder if anyone can help. I have created a .htaccess file and put the following in it. Then uploaded. But when I input the old url, it shows up and does not redirect to the new url. What have I done wrong? Can anyone advise? Thank you. (the urls are just examples here as I don't want to post my client's site). But the .htm and the .php are the same.Thanks.

 

Redirect 301 /old/old_old.htm /new/http://www.newsite.com/index.php'>http://www.newsite.com/index.php'>http://www.newsite.com/index.php

 

 

P.s I have also tried the following:

 

Redirect 301 old_old.htm http://www.newsite.com/index.php

 

and

 

Redirect 301 /old_old.htm http://www.newsite.com/index.php

 

and

 

Redirect 301 old.htm http://www.newsite.com/index.php

 

and none of that works.

  • Author

Here's a link to a page that shows you how: 301 redirect

 

Thanks but it's not the whole domain that I need to redirect. The site has been re-designed and I want to redirect all the old pages to the new index page. I was told to do it the way I already put, but that doesn't seem to work so am now wondering if there are reasons for this or if I have done it the wrong way.

Thanks. Yup, did that but still the same. Any other ideas?

Can you post the entire contents of your .htaccess file here and let me know the file is named correctly and you have the rights etc to modify that file on your server and I'll see what might be awry. Thanks.

  • Author

Can you post the entire contents of your .htaccess file here and let me know the file is named correctly and you have the rights etc to modify that file on your server and I'll see what might be awry. Thanks.

 

I found out from the hosting company that they disallow 301 redirects so i will need to find another way entirely to do the redirection. Thanks for your suggestions anyways.

The problem, I think with not being able to use .htaccess is the 301 code will not be passed. Resulting in a straightforward redirect as opposed to permanently moved.

 

I found this which is a meta redirect

<meta http-equiv="refresh" content="10;
url=http://mynewsite.com/">

 

But the caveat is, apparently it takes 10 seconds to do the redirect – although this can be modified to 0 – and is know as a spam method by search engines, chipping away at your google love.

 

The best alternative would be to redirect using php as you can supply the header to the searchengine for a 301 Redirect

 

Place this before the <html> tag and rename the file with the .php extension:

 

<?php
// Permanent redirection
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.yourdomain.com/yourfile.html");
exit()
?>

 

This will of course be dependent on your support of php (Your server should, if it doesn't, move hosts) and the renaming of the file to redirect to 'filename.php'

Slightly better way of writing it

 

<?php
// Permanent redirection
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.yourdomain.com/your-redirection-location.html");
exit();
?>

Slightly better way of writing it

 

<?php
// Permanent redirection
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.yourdomain.com/your-redirection-location.html");
exit();
?>

Yup- that is your next best bet.

 

I was beginning to wonder why your htaccess wasn't working and I would consider moving your site to another host if you can't use htaccess the way you need to and getting your 301's right is so key.

  • 2 weeks later...

Sorry I haven't re-replied. Find a new host. I can do your hosting at a low price and don't disallow things necessary for running a good website :) message me if you'd like to speak more.

I stumbled on this today.. best 301 resource i have found yet.. may help someone

RewriteEngine on 
RewriteCond %{QUERY_STRING} ^id=13$
RewriteRule ^/page.php$ http://www.example.com/newname.htm? [L,R=301]

I just wondered if you resolved this issue.

 

A permanent 301 in an .htaccess file would be best as a meta redirect could be seen by Google as possibly underhanded. A meta redirect set to the following would work quite happily and may not cause you an issue.

 

It should always be in "lower case" and either this:

 

<meta http-equiv="refresh" content="0; url=http://www.yourdomain.com/index.html"> for doc type strict.dhd

 

<meta http-equiv="refresh" content="0; url=http://www.yourdomain.com/index.html" /> transitional.dhd (i.e />)

 

Used on a standard html file with blank title.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.