.htaccess rewrite rule to ignore a directory
        Posted  
        
            by 
                Kirk Strobeck
            
        on Server Fault
        
        See other posts from Server Fault
        
            or by Kirk Strobeck
        
        
        
        Published on 2013-10-29T21:53:49Z
        Indexed on 
            2013/10/29
            21:57 UTC
        
        
        Read the original article
        Hit count: 421
        
.htaccess
I am running a Symphony installation out of the directory symphony but I want to remove that word from the URL in specific cases.
When a user visits
http://domain.com/demo
It should go to
http://domain.com/symphony/demo
because I've added a specific rule for demo. If I haven't added a specific rule for demo in the .htaccess, then it should resolve to 
http://domain.com/demo
as typed. This will route it to another part of our app.
Here is my current rewrite rule
### Symphony 2.3.x ###
Options +FollowSymlinks -Indexes
<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteBase /
    ### SECURITY - Protect crucial files
    RewriteRule ^manifest/(.*)$ - [F]
    RewriteRule ^workspace/(pages|utilities)/(.*)\.xsl$ - [F]
    RewriteRule ^(.*)\.sql$ - [F]
    RewriteRule (^|/)\. - [F]
    ### DO NOT APPLY RULES WHEN REQUESTING "favicon.ico"
    RewriteCond %{REQUEST_FILENAME} favicon.ico [NC]
    RewriteRule .* - [S=14]
    ### IMAGE RULES
    RewriteRule ^image\/(.+\.(jpg|gif|jpeg|png|bmp))$ extensions/jit_image_manipulation/lib/image.php?param=$1 [B,L,NC]
    ### CHECK FOR TRAILING SLASH - Will ignore files
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_URI} !/$
    RewriteCond %{REQUEST_URI} !(.*)/$
    RewriteRule ^(.*)$ $1/ [L,R=301]
    ### URL Correction
    RewriteRule ^(symphony/)?index.php(/.*/?) $1$2 [NC]
    ### ADMIN REWRITE
    RewriteRule ^symphony\/?$ index.php?mode=administration&%{QUERY_STRING} [NC,L]
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^symphony(\/(.*\/?))?$ index.php?symphony-page=$1&mode=administration&%{QUERY_STRING}   [NC,L]
    ### FRONTEND REWRITE - Will ignore files and folders
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*\/?)$ index.php?symphony-page=$1&%{QUERY_STRING}    [L]
</IfModule>
######
How would I change the rewrite rule to support those cases?
© Server Fault or respective owner