views:

155

answers:

2

I am creating URLs in my website as

http://example.com/register/

http://example.com/login/

I am creating above URLS by writing following rules in htaccess

RewriteRule register/ /register.php

RewriteRule login/ /login.php

Now its working fine for me, but if I create my URLs by creating seprate folder for /login/index.php and /register/index.php By creating folders and index.php files inside those I can achieve above functionality easily.

But I want to know which w=one will be faster, I tried both methods but not seen much difference, according to logic and apache specifications and everything which method will be faster and a good method to go with.

My friend says .htaccess rules will be slower, because in case of htaccess first it will check for rules and then it will redirect to the corresponding attached page, this process will take time than folder organization.

+2  A: 

.htaccess will be slower, but the time difference will be negligible.

You should concentrate on other things - like which one is easier to maintain.

Greg
Which one you think will be easier to maintain?? According to me its htaceess.
Prashant
I think time differnce is nothing because every social media site, Digg, mixx and anyother using htaccess apache for url rewrite and they are doing well...
Prashant
I guess most big websites do not allow .htaccess but use RewriteRules in their apache config files, so there will be no need to search for .htaccess files at every request.
Residuum
@Residuum how can we do that, we have our own server so that we can make any changes in our apache config files, can you please share any article or some knowledge base article which will guide us to do that??
Prashant
@Prashant it's the same code as .htaccess (except urls start with /, so instead of ^foo you'd use ^/foo) - just put it in the right virtual host section.
Greg
+3  A: 

I know that .htaccess will at least be easier for development/debugging purposes because:

1) Because all of your files will be in the same directory instead of their individual ones. 2) Because your editor will show the actual filenames instead of multiple index.php.

Also, since you're using .htaccess, this makes it easier to put a rule in such as:

RewriteRule ^getdata/(\d+)/$ getdata.php?page=$1

Which you can't do when using the directory-based methods.

Overall, the speed difference is negligible compared to the benefits available from using mod_rewrite.

MiffTheFox