Solved

Is rewrite using htaccess is slower than folder based URLs?

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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
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…

803 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