Solved

Is rewrite using htaccess is slower than folder based URLs?

Posted on 2009-07-08
2
219 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
Envision that you are chipping away at another e-business site with a team of pundit developers and designers. Everything seems, by all accounts, to be going easily.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This video teaches users how to migrate an existing Wordpress website to a new domain.

705 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

18 Experts available now in Live!

Get 1:1 Help Now