[Pro] 301 Redirects

Hi everyone,

Just starting to understand that there are different versions of my URL out there and it can be best to have the all link to the ‘clean’ version of my URL.

i.e. non WWW versions redirected to my WWW URL

As I understand it, this is called a 301 redirect.

Has there been an Action written which helps with this problem.

I might also add, this is getting to the limit of my knowledge of the subject, so please treat me as a layman! :slight_smile:

Hope you can help.

Mark


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

On Nov 1, 2012, at 6:14 AM, Mark Lawrence wrote:

Hi everyone,

Just starting to understand that there are different versions of my URL out there and it can be best to have the all link to the ‘clean’ version of my URL.

i.e. non WWW versions redirected to my WWW URL

As I understand it, this is called a 301 redirect.

Has there been an Action written which helps with this problem.

No, because Freeway cannot create a file that begins with a ‘.’ – that makes it invisible in the Finder. The way this is managed on most of the servers in the world is with what’s called an .htaccess file.

I might also add, this is getting to the limit of my knowledge of the subject, so please treat me as a layman! :slight_smile:

If you have Fetch, or CyberDuck, or Transmit (my favorite), first log in to your host, and then turn on the option to “show hidden files” in your FTP application. You will probably see a bunch of files you never worried about before, likely to do with logging visits to your site, or the control panel, or similar.

Look in your site folder (htdocs, public_html, www – it can be named literally anything – it will be the folder that also contains your index.html file) for a file named .htaccess. If you don’t see one, you can create one with your FTP application. Once you do, double-click it to open in your default editor. (Transmit has a built-in editor that is perfect for these sorts of things.)

If you already have one, then you will see the base directives for your site. Don’t edit them, just add new directives to the bottom of the file. Look carefully through the existing directives to see if you see this line:

RewriteEngine On

If you do, don’t add it a second time as I indicate below; drop that direction from the following ones.

Edit the following to match your real domain name, and add to your .htaccess file:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]

This will redirect all requests for all pages to the “bare” domain to the www subdomain. The redirect will tell the client unambiguously, “this resource has moved permanently – don’t come back looking for it here any more”. That’s what the 301 means.

Now save the .htaccess file and refresh your browser. If you still see your site, then the redirect will work. If you see a nasty 500 error (Server Configuration Failure) then you will have to delete or rename the .htaccess file and ask your hosting provider what to do next. They may have configured their server to not allow you to enable rewriting, or they may not have mod_rewrite installed. Either way, it’s out of your control, and you’ll have to file a support ticket to get it resolved.

Walter


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Hi Walt,

This is what it shows:

AddHandler phpCGI .php .phtml .php3
Action phpCGI /cgi-bin/phpCGI

for php4 and securewebexchange

AddHandler phpCGI .php .phtml .php3 Action phpCGI https://secure25.securewebsession.com/alternative-angles.com/cgi-bin/phpCGI

Am I right in thinking I should just paste the code in after this as below:

AddHandler phpCGI .php .phtml .php3
Action phpCGI /cgi-bin/phpCGI

for php4 and securewebexchange

AddHandler phpCGI .php .phtml .php3 Action phpCGI https://secure25.securewebsession.com/alternative-angles.com/cgi-bin/phpCGI

RewriteEngine on
RewriteCond %{HTTP_HOST} ^alternative-angles.com$ [NC]
RewriteRule ^(.*)$ http://www.alternative-anlges.com.com/$1 [R=301,L]


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Yes, precisely. Give that a try. And if you’re at all serious about using PHP, get another hosting provider for that. CGI is very late-90s tech in PHP.

Walter

On Nov 1, 2012, at 1:01 PM, Mark Lawrence wrote:

Hi Walt,

This is what it shows:

AddHandler phpCGI .php .phtml .php3
Action phpCGI /cgi-bin/phpCGI

for php4 and securewebexchange

AddHandler phpCGI .php .phtml .php3 Action phpCGI https://secure25.securewebsession.com/alternative-angles.com/cgi-bin/phpCGI

Am I right in thinking I should just paste the code in after this as below:

AddHandler phpCGI .php .phtml .php3
Action phpCGI /cgi-bin/phpCGI

for php4 and securewebexchange

AddHandler phpCGI .php .phtml .php3 Action phpCGI https://secure25.securewebsession.com/alternative-angles.com/cgi-bin/phpCGI

RewriteEngine on
RewriteCond %{HTTP_HOST} ^alternative-angles.com$ [NC]
RewriteRule ^(.*)$ http://www.alternative-anlges.com.com/$1 [R=301,L]


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Thanks Walt, I’ll look into another host provider, almost time to switch anyway.

Just to clarify in my own mind, adding the above piece of code helps to direct any short URL google searches to my main WWW url, that’s right isn’t it?

M :slight_smile:


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Yes. Technically, www.example.com is a subdomain, not a domain. It is common practice to use www to mean Web, but it’s not strictly necessary or otherwise meaningful. It’s not the same thing as the protocol part of the URL – http:// – which literally means “this address is to a standard Web server, and unless you’re told otherwise, at port 80.”

I’m not sure if Google actually cares about this any more – it’s been a very long time since this was first announced as being a potential problem, and browsers and bots are much smarter and more full of defaults these days, so I doubt seriously that they would punish you for “duplicate content” between www.example.com and example.com. The punishment is reserved for sites that try to spam them, for example:

www.example.com
widgets.example.com
lancaster-widgets.example.com
pittsburgh-widgets.example.com

with all of those pointing to the same site. That would be more likely to get you on the very wrong side of Google.

Walter

On Nov 1, 2012, at 2:27 PM, Mark Lawrence wrote:

Thanks Walt, I’ll look into another host provider, almost time to switch anyway.

Just to clarify in my own mind, adding the above piece of code helps to direct any short URL google searches to my main WWW url, that’s right isn’t it?

M :slight_smile:


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options