An .htaccess for our entire site We have this long .htaccess mainly rewriting our URLs. Everything works fine (except blog titles containing a ' , but we're working on that) but I'm sure it can be shorter. Feel free to review our code and propose some generic or simpler ways to rewrite the URLs instead of rewriting each and every concerned page like the example below. 

Options +FollowSymlinks
RewriteEngine on

RewriteCond %{HTTP_HOST} ^oursite\.site$ [OR]
RewriteCond %{HTTP_HOST} ^www\.oursite\.site$
RewriteRule ^admin\/?$ "http\:\/\/oursite\.site\/admin\/connexion" [R=301,L]

# Rewrite spaces as long as there are more than 1 spaces in URI
RewriteRule "^(\S*)\s+(\S*\s.*)$" /$1-$2 [L,NE]

# Rewrite spaces when there is exactly 1 space in URI
RewriteRule "^(\S*)\s(\S*)$" /$1-$2 [L,R=302,NE]

#Redirect non-www to www
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]


#Rewrite urls blog
RewriteRule blog/(.*)/([0-9]+)-(.*)$ blogpost.php?brand=$1&amp;blog_id=$2&amp;titre=$3

#Rewrite urls brands
RewriteRule brand/([0-9]+)-(.*) brand.php?id=$1&amp;brand=$2

#Rewrite urls shop brands
RewriteRule shop/brands/([0-9]+)-(.*) shopbrand.php?id=$1&amp;brand=$2

#Rewrite urls shop category
RewriteRule shop/category/([0-9]+)-(.*) shopcategory.php?id=$1&amp;cat_nom=$2

#Rewrite ADMIN profile
RewriteRule admin/([0-9]+)-([a-zA-Z0-9\-]+)/profil$ admin/profil.php?user_id=$1&amp;brand=$2  

#Rewrite ADMIN panel
RewriteRule admin/([0-9]+)-([a-zA-Z0-9\-]+)/panel$ admin/panel.php?id=$1&amp;brand=$2

#Rewrite ADMIN panel-blog
RewriteRule admin/([0-9]+)-([a-zA-Z0-9\-]+)/blog$ admin/panel-blog.php?id=$1&amp;brand=$2

#Rewrite ADMIN panel-blog-add
RewriteRule admin/([0-9]+)-([a-zA-Z0-9\-]+)/blog-add$ admin/panel-blog-add.php?user_id=$1&amp;user_brand=$2 

#Rewrite ADMIN panel-blog-modif
RewriteRule admin/([0-9]+)-([a-zA-Z0-9\-]+)/blog-modif$ admin/panel-blog-modif.php?id=$1&amp;brand=$2

#Rewrite ADMIN post-modif
RewriteRule admin/([0-9]+)-([a-zA-Z0-9\-]+)/post-modif/([0-9]+)$ admin/post-modif.php?user_id=$1&amp;user_brand=$2&amp;blog_id=$3

#Rewrite ADMIN add
RewriteRule admin/([0-9]+)-([a-zA-Z0-9\-]+)/add$ admin/add.php?user_id=$1&amp;user_brand=$2

#Rewrite ADMIN update
RewriteRule admin/([0-9]+)-([a-zA-Z0-9\-]+)/update/([0-9]+)$ admin/update.php?user_id=$1&amp;user_brand=$2&amp;blog_id=$3

#Rewrite ADMIN delete
RewriteRule admin/([0-9]+)-([a-zA-Z0-9\-]+)/delete/([0-9]+)$ admin/delete.php?id=$1&amp;brand=$2&amp;blog_id=$3

#Rewrite ADMIN panel-prod
RewriteRule admin/([0-9]+)-([a-zA-Z0-9\-]+)/boutique$ admin/panel-prod.php?id=$1&amp;brand=$2

#Rewrite ADMIN panel-prod-add
RewriteRule admin/([0-9]+)-([a-zA-Z0-9\-]+)/boutique-add$ admin/panel-prod-add.php?id=$1&amp;brand=$2 

#Rewrite ADMIN panel-prod-modif
RewriteRule admin/([0-9]+)-([a-zA-Z0-9\-]+)/boutique-modif$ admin/panel-prod-modif.php?id=$1&amp;brand=$2

#Rewrite ADMIN prod-modif
RewriteRule admin/([0-9]+)-([a-zA-Z0-9\-]+)/produit-modif/([0-9]+)$ admin/prod-modif.php?id=$1&amp;brand=$2&amp;prod_id=$3

#Rewrite ADMIN prod-add
RewriteRule admin/([0-9]+)-([a-zA-Z0-9\-]+)/produit-add$ admin/prod-add.php?user_id=$1&amp;user_brand=$2

#Rewrite ADMIN prod-update
RewriteRule admin/([0-9]+)-([a-zA-Z0-9\-]+)/produit-update/([0-9]+)$ admin/prod-update.php?id=$1&amp;brand=$2&amp;prod_id=$3

#Rewrite ADMIN prod-delete
RewriteRule admin/([0-9]+)-([a-zA-Z0-9\-]+)/produit-delete/([0-9]+)$ admin/prod-delete.php?id=$1&amp;brand=$2&amp;prod_id=$3

#Rewrite ADMIN faq
RewriteRule admin/([0-9]+)-([a-zA-Z0-9\-]+)/faq$ admin/faq.php?id=$1&amp;brand=$2

#Remove php extensions
RewriteCond %{REQUEST_FILENAME}.php -f 
RewriteRule ^(.*)$ $1.php [L] 

ErrorDocument 404 http://oursite.site/404

#CACHESYSTEM
&lt;FilesMatch "(?i)^.*\.(ico|flv|jpg|jpeg|png|gif|js|css)$"&gt;
ExpiresActive On
ExpiresDefault A2592000
&lt;/FilesMatch&gt;

#MAINTENANCE SYSTEM (if required)
#RewriteCond %{REQUEST_URI} !/maintenance.php$
#RewriteCond %{REMOTE_ADDR} !^555\.555\.555\.555
#RewriteRule $ /maintenance [R=302,L]
Unfortunately I don't think there is much you can do here because of how the targets of your regexes are different. I was going to say you could change some of these to use groups, for example:

RewriteRule blog/(.*)/([0-9]+)-(.*)$ blogpost.php?brand=$1&amp;blog_id=$2&amp;titre=$3
RewriteRule brand/([0-9]+)-(.*) brand.php?id=$1&amp;brand=$2
RewriteRule shop/brands/([0-9]+)-(.*) shopbrand.php?id=$1&amp;brand=$2


These all end with the pattern ([0-9]+)-(.*) so you almost could extract the first part and use that file, like this:

RewriteRule (.*)/([0-9]+)-(.*)$ $1?id=$2&amp;brand=$3


However you can't because e.g. shop/brands doesn't match shopbrand.php (and not everything has brand=). There just isn't enough commonality in the paths to make this sort of thing feasible.

If your goal is to simply get rid of .htaccess, using a script and using a dispatcher with PHP logic would be an alternative, as stated in the question comments. Personally I don't think that would be any simpler though, I think it would just be moving the "problem" into a different file--one that Apache needs to start up a PHP thread/process to solve, instead of doing it on its own.

The only way, IMHO, to improve this situation would be to architect the site differently and/or abandon the old URLs so you don't need to rewrite them. If you can change what the URLs are, then I would suggest switching to a single index.php dispatcher and MVC or REST pattern (or use a framework that handles this, like Symfony).