.htaccess tutorial

htaccess Elite


mod_rewrite Efficiency Question

Ask your mod_rewrite and Redirection questions here, and get answers!

mod_rewrite Efficiency Question

Postby produke » 02 Oct 2006 01:58

Hey I am one of those people that hasn't taken the time to learn the rewrite regex rules. So I can manage but I cringe because I know it could be done better.

My question should be pretty easy for you guys-

Current htaccess Rewrites
Code: Select all
1. RewriteRule ^ic/(.*) includes/css/$1 2.
RewriteRule ^ij/(.*) includes/javascript/$1 3.
RewriteRule ^ii/(.*) includes/images/$1 4.
RewriteRule ^is/(.*) includes/swf/$1 5.
RewriteRule ^po/i/(.*) products/individual/$1 6.
RewriteRule ^po/b/(.*) products/business/$1 7.
RewriteRule ^po/(.*) products/$1 8.
RewriteRule ^scripts/(.*)\.pl$ /cgi-bin/$1.php


Notice how #7 seems to be redundant or something? Shouldn't I be able to move #7 above 5 and 6 and shorten the code?



This enables me to have a verbose file structure so maintaining the site is easy and clear. But to make my XHTML cleaner and simpler and smaller (bytes) I reference files like so-
Code: Select all


products/ po/
products/business/ po/b/
products/individual/ po/i/
includes/css/ ic/
includes/javascript/ ij/
includes/images/ ii/
includes/swf/ is/





Before I used poi/ and pob/ but I changed that to make my applications like breadcrumbs, php, etc work more logically.

This isn't a crucial thing that I need right now, I more want to learn and discuss the best-practices way of rewrites for this particular use. Please help me out! Peace out
Last edited by produke on 01 Nov 2006 09:29, edited 1 time in total.
User avatar
produke
 
Posts: 242
Joined: 25 Sep 2006 04:48

Postby produke » 02 Oct 2006 01:59

One solution provided by extras is to use symlinks

Code: Select all
<?php
# NAMED test.php in my /public_html folder on the new server platform
echo '<pre>';


echo `ln -sv includes/axs ia 2>&1`;
echo `ln -sv includes/css ic 2>&1`;
echo `ln -sv includes/images ii 2>&1`;
echo `ln -sv includes/javascript ij 2>&1`;


echo '</pre>';
?>
User avatar
produke
 
Posts: 242
Joined: 25 Sep 2006 04:48


Return to Redirect or Rewrite Questions