spiderwell Posted January 2, 2012 Share Posted January 2, 2012 hi all, i have researched this, and tried many variations to get this to work but it just doesnt seem to like it. I hopeing there is someone here who can fix this for me. I am writing my own mvc system, more as an exercise than anything . i use rewrite to pass everything through the same file. that was all working fine. <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?url=$1 [PT,L] </IfModule> i wanted to add a rewrite for admin calls to go via a specific directory getting re written to a file called admin.php. so to try and put in layman terms any call starts with www.mysite.com/a/ goes to www.mysite.com/admin.php and anything else is covered by the original rewrite rule. i tried this but it only seems to break it <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(a/.*) admin.php?url=$1 [PT,L] RewriteRule ^(.*)$ index.php?url=$1 [PT,L] </IfModule> i spent ages on this and i know some genius out there can crack it for me in 5 mins! thanks and HNE! Quote Link to comment Share on other sites More sharing options...
requinix Posted January 2, 2012 Share Posted January 2, 2012 RewriteConds and (a single) RewriteRule go together as a set. If you want a more specific rule than "everything goes through index.php" then add another set of Conds+Rule before the generic rule. Quote Link to comment Share on other sites More sharing options...
spiderwell Posted January 2, 2012 Author Share Posted January 2, 2012 i tried this <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(a/.*)$ admin.php?url=$1 [PT,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?url=$1 [PT,L] </IfModule> it doesnt seem to to take any notice of it Quote Link to comment Share on other sites More sharing options...
spiderwell Posted January 3, 2012 Author Share Posted January 3, 2012 well it doesnt work at all on my live environment!! haha damn i hate HTaccess Quote Link to comment Share on other sites More sharing options...
spiderwell Posted January 3, 2012 Author Share Posted January 3, 2012 I just put the whole thing on my domain and now it wont do any of the redirect! does anyone have any suggestions? thanks Quote Link to comment Share on other sites More sharing options...
requinix Posted January 4, 2012 Share Posted January 4, 2012 1. Does your server have mod_rewrite enabled? 2a. How do you know it doesn't work? Are admin.php and index.php not running at all, or are they not running correctly? 2b. Could it be that admin.php wants the page name without the "a/" path? Quote Link to comment Share on other sites More sharing options...
spiderwell Posted January 5, 2012 Author Share Posted January 5, 2012 1. according to my hosts it does, but shot off a ticket just incase 2a. i went back to the single redirect on the live server as i know that works fine, it doesnt seem to redirect with this on the live site 2b. admin.php load up the display html only and nothing else. i see what the hosts come back with first but im more inclinded to think its my htaccess only because i dont really know how to write it . im still interesting in getting my original query working local too, with 2 redirects in place. its limiting my advancement, as im using the url to tell the controller script what to do /user/edit/?id=5 kinda thing Quote Link to comment Share on other sites More sharing options...
spiderwell Posted January 9, 2012 Author Share Posted January 9, 2012 well i got it working in the end from lot so trial and error! however this is only on my local server using WAMP on my computer, doesnt seem to like it on the live site i shall try and work out why! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.