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

[eluser]Daniel Moore[/eluser]
If you already have an .htaccess, then it's a no brainer that it would be more efficient to do it within an .htaccess file.

If you do not have one, and the server is configured to allow .htaccess, then if the server is checking every directory for .htaccess anyway, and loading the CodeIgniter framework before the redirect, then having to load it again after redirect, is going to be slower by far. Simple fact that the server's disk must access much more data, and we all know that disk access is not the fastest way to go, even if it is often times the only way to go.

If you have a server with no .htaccess access, then the hook is the only way. Use it then. Then again, with no .htaccess, the server probably has other restrictions that will make using CodeIgniter problematic anyway.

My 2 cents.
#12

[eluser]Vangelis B[/eluser]
It's way too obvious that an .htaccess redirect will be faster than even a simple .html file.

Obviously both methods have advantages and disadvantages. The hook approach is not only more portable but allows a few other goodies as well if you want to extend it. For example you can log the times someone entered your site through the "wrong" URL or log the referring link (so you won't have to look around at the chaos of apache access logs). This way you can easily inform people linking to your page to correct their links.

@wiredesignz: FYI I didn't go with the hook because I didn't know the .htaccess code but because I had problems with hosts in the past and avoid such practices.
#13

[eluser]Iverson[/eluser]
[quote author="Daniel Moore" date="1242416764"]
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.[/quote]

Not necessarily. No one is arguing about the efficiency of having a shared host that allows .htaccess files. Vangelis is simply giving a much more universal solution. This is common practice in the CI community. Just like CI sets certain global environment variables just in case you don't have access to the php init file. The CI developers didn't say "if you can't set your display_error variables or turn short tags on/off, you need to change hosts!". They simply made a much more portable solution that will eliminate problems and allow more people to use the code. I hate when people make comments about changing the environment versus coming up with a solution for the environment they're in. Obviously we would all have an ideal environment if we could.

And just because you can create/edit an htaccess on your host doesn't mean it will perform the tasks you want it to. Many hosts limit what an htaccess file can do.

Also, although the server side redirect would be faster, it wouldn't be so noticeable to an end-usr that it would cause that big of a headache.
#14

[eluser]Daniel Moore[/eluser]
[quote author="Iverson" date="1242769350"][quote author="Daniel Moore" date="1242416764"]
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.[/quote]

Not necessarily. No one is arguing about the efficiency of having a shared host that allows .htaccess files. Vangelis is simply giving a much more universal solution. [/quote]

I understand having a more universal solution. I'm all for ways to do things that do not depend on the host. It is always a good idea to have a backup way of doing things that will be universal. I have even filed the hook method away, just in case, but will continue to use the .htaccess as long as it is not a problem to do so.

However, what I was stating was that if the host so restricts .htaccess that you can't do a simple redirect, then this host is going to be too restrictive to allow full-blown PHP applications to run smoothly.

I've only dealt with one host in the last 6 years that did not allow .htaccess, and they didn't support PHP either. It was for a plain HTML site for a relative. It was free for them, so the price was right.

In today's marketplace, if a hosting provider cannot provide a way to do a redirect with a .htaccess file given the competition in the market, that host probably won't survive long. Better to find a host that is being competitive. That's host shopping advice, not coding advice, and it's good advice.

I didn't go into that part of it further because it's really not on topic.

On another note, if you're just developing an application for distribution/sales to people who may want an install script but may not be able to tweak a .htaccess file, then the hook method would definitely be the one to go with.




Theme © iAndrew 2016 - Forum software by © MyBB