Solved

Is rewrite using htaccess is slower than folder based URLs?

Posted on 2009-07-08
2
229 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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…
The viewer will learn how to dynamically set the form action using jQuery.

763 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