Jump to content

2 rewrite rules not working together


spiderwell

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/254197-2-rewrite-rules-not-working-together/
Share on other sites

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

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?

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 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.