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
Solved

Is rewrite using htaccess is slower than folder based URLs?

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Any business that wants to seriously grow needs to keep the needs and desires of an international audience of their websites in mind. Making a website friendly to international users isn’t prohibitively expensive and can provide an incredible return…
Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

808 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