Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Will RewriteRules In .htaccess Affect Site's Speed?

I am planing to add at most 10 .htaccess rewrite url codes in home directory will it affect execution ( loading time of site ) of my website ?

my current .htaccess file is

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^([0-9]+)/([0-9]+)/([^.]+).html index.php?perma=$3
RewriteRule ^movies/([^.]+).html gallery.php?movie=$1
RewriteRule ^album/([^.]+).html gallery.php?album=$1
RewriteRule ^img/([^.]+)/([^.]+).html gallery.php?img=$2
RewriteRule ^movies.html gallery.php
like image 337
Rahul R Avatar asked Feb 08 '13 06:02

Rahul R


People also ask

What is Rewriterule in htaccess?

htaccess rewrite rules can be used to direct requests for one subdirectory to a different location, such as an alternative subdirectory or even the domain root. In this example, requests to http://mydomain.com/folder1/ will be automatically redirected to http://mydomain.com/folder2/.

What is Rewriterule?

L|last. The [L] flag causes mod_rewrite to stop processing the rule set. In most contexts, this means that if the rule matches, no further rules will be processed. This corresponds to the last command in Perl, or the break command in C.

What is mod_rewrite used for?

mod_rewrite provides a flexible and powerful way to manipulate URLs using an unlimited number of rules. Each rule can have an unlimited number of attached rule conditions, to allow you to rewrite URL based on server variables, environment variables, HTTP headers, or time stamps.

Where is mod_rewrite so?

The mod_rewrite module is enabled by default on CentOS 7. If you find it is not enabled on your server, you can enable it by editing 00-base. conf file located in /etc/httpd/conf. modules.


2 Answers

Yes it will affect the load time. The more rules/exceptions you have, the longer it takes to render. But: we are talking about micro/milliseconds that won't be even noticed by the human eye.

like image 154
Kevin Avatar answered Nov 14 '22 23:11

Kevin


You might need to see performance impact of order of rewrite rules when using apache mod_rewrite and, like @diolemo commented, for 20 rewrite rules it's not noticeable.

like image 43
vectorialpx Avatar answered Nov 14 '22 23:11

vectorialpx