Solved

Is rewrite using htaccess is slower than folder based URLs?

Posted on 2009-07-08
2
222 Views
Last Modified: 2012-05-07
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.
0
Comment
Question by:proteam4
2 Comments
 
LVL 8

Expert Comment

by:yfastud
ID: 24806661
depends on contents of your htaccess and it would take longer time if and only if you have too many rules in 1 htaccess; however, most users would not notice that since it occurs in server before delivery to users ;)
0
 
LVL 9

Accepted Solution

by:
pmessana earned 500 total points
ID: 24808823
As vfastud says it would depend on the size of the htaccess, however, keep something else in mind, if you do what you originally laid out you can easily keep track of files and depending on how you are editing them you will get confused if you have a ton of index.php files.

Personally I prefer the file to be login.php and use the rewrite, we use thousands of rewrites this way and manage the htaccess file when new pages are loaded, it seems to work nicely for us, we can test it by directly accessing and then turn it on by loading it in the htaccess file and updating links.

If you don't like either solution and want another alternative you can use the ForceType to force all files to treat it as if it had the .php extension, this means that all files can lose their extension.  The issue here is that most editors do not recognize the file without an extension, we managed it this way for a while where we built a deployment script that stripped off the extension and then we did the ForceType to force it to process it as PHP.  Doing it this way means you don't have to worry about a million .htaccess directives either, you have the one to treat all files as PHP files in the directory.

0

Featured Post

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

948 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now