Mod Rewrite in directory issues

Discussion in 'Apache' started by xxKillswitch, Dec 27, 2008.

  1. #1
    I can't seen to figure this problem out after consulting the faq on the issue and Google. I have written a custom CMS and trying to touch up the Mod Rewrite work done.

    The site in the main directory works fine with my rules, however, I found the need to install a directory with the CMS to test out another site and it doesn't work that well...

    I have the rules set up so that when you visit localhost/category you are 301 redirected to localhost/category/ , just appending the / at the end simulating a directory.

    In the directory, when I try to access this the redirect directs from localhost/webmasters/category to localhost/category/. Here is my htaccess rules...

    Options +FollowSymlinks
    RewriteEngine On
    RewriteBase /webmasters/
    
    # Write categories that do not end with a trailing slash
    # to end with a trailing slash ( 301 redirect )
     
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_URI} !(.*)/$
    RewriteCond %{REQUEST_URI} !.html$
    
    RewriteRule ^(.*)$ /$1/ [L,R=301]
    
    # Core rewrites
    # Handles the primary rewrite, CMS handles the rest :D
    
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteRule ^(.*) $1 [L]
    RewriteCond %{REQUEST_URI} !-d
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?category=$1/ [L]
    RewriteRule ^([a-z_]+)/([^/]+/)$ index.php?category=$1
    Code (markup):
    This might get even more confusing in the fact that only one rewrite is needed, its only on the first index.php?Category=whatever. I've exploded the URL into parts starting from $_GET['category'] ( if you don't know PHP, sorry ), so the anything following /category/ I can get without the need for mod rewrite. This solution ended up much more simply in the end, aside from writing the htaccess ( which I don't have a problem with other than being in sub directory ).

    Any help on this? Been confusing me for so long now...
     
    xxKillswitch, Dec 27, 2008 IP