Welcome Guest, Not a member yet? Register   Sign In
Taking care of the www issue
#1

[eluser]Vangelis B[/eluser]
A lot of talk has been done about whether sites should use the www subdomain or not. Either way you can overcome this by using a small hook.

Taking care of the www issue
#2

[eluser]Dam1an[/eluser]
If you want to make this transparent to the end user, you can use htaccess (I don't have the example to hand, as I saw it a long time ago, but you could probably easily find it)

Another reason to do this, is so that all your google page rank is for one site, as oppose to split accross 2 domain
#3

[eluser]Vangelis B[/eluser]
Yes i'm aware of the .htaccess solution. However both methods are equally transparent to the end user and SEO friendly. Although google recommends .htaccess it equally accepts the 301 redirection. So both ways you don't loose pagerank or annoy the end user.

I choose to go with hook solution because I consider it to be more portable in cases where you got a lame host or for any reason you don't have access to .htaccess.
#4

[eluser]drewbee[/eluser]
I do this with htaccess myself, but to each his/her own!!
#5

[eluser]Daniel Moore[/eluser]
[quote author="Vangelis B" date="1242413996"] Although google recommends .htaccess it equally accepts the 301 redirection. So both ways you don't loose pagerank or annoy the end user.
[/quote]

The .htaccess performs a 301 redirection.

[quote author="Vangelis B" date="1242413996"]
I choose to go with hook solution because I consider it to be more portable in cases where you got a lame host or for any reason you don't have access to .htaccess.[/quote]

If you've got a host that doesn't give access to .htaccess, you need to change hosts. There are bound to be much more serious issues than a lack of .htaccess there. Those hosts may be fine for putting up a single, personal web page in HTML only, but would not be acceptable for setting up PHP applications, IMHO.

Both methods are equally valid. I wouldn't use the "portable" as an issue, however. It would be interesting to see a benchmark of which one is more efficient, however.

One thing about the .htaccess method that the CodeIgniter hook can't handle, and that's when you hand-off from CodeIgniter to a 3rd party software, like vBulletin, WordPress, Simple Machines Forum, etc., the .htaccess will continue to redirect, but the hook will not. This keeps you from duplicating or splitting your page ranking for 3rd party software installations.

I know we all would like to stay away from 3rd party software, but let's face it. Sometimes we have to use it.

That's the reason I prefer to stick with the .htaccess method.
#6

[eluser]Dam1an[/eluser]
@Daniel: Good points as always, especially with the 3rd party stuff
I would assume the htaccess would be marginally quicker, but I doubt there's much in it

Now if only I wasn't too lazy/busy to do the benchmarks Wink
#7

[eluser]wiredesignz[/eluser]
An .htaccess (Server) redirect is far more efficient than a PHP (interpreted language) redirect. No comparison there.
#8

[eluser]Vangelis B[/eluser]
It is an HTML redirect actualy. PHP as a server side language is incapable or performing redirects
#9

[eluser]Dam1an[/eluser]
[quote author="wiredesignz" date="1242417504"]An .htaccess (Server) redirect is far more efficient than a PHP (interpreted language) redirect. No comparison there.[/quote]

Do you have any benchmarks to show by how much? (Note: I don't need benchmarks as proof, cause I beleive you, I just want to know if its a significant difference)
#10

[eluser]wiredesignz[/eluser]
[quote author="Vangelis B" date="1242418496"]It is an HTML redirect actualy. PHP as a server side language is incapable or performing redirects[/quote]

You are being ridiculous, stop picking points, the server loads PHP which loads the framework and renders an HTML redirect (using HTML headers) compared with the server itself doing the same job.

FYI, here is the .htaccess code to do your redirect.
Code:
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]




Theme © iAndrew 2016 - Forum software by © MyBB