Jump to content

Using mod rewrite in root and then a subfolder


Go to solution Solved by Lyleyboy,

Recommended Posts

Hey all,

 

I have a site that uses mod rewrite. It's working fine for the main site.
Now I need to build an admin panel and I'd like that to use mod re write too.

 

So www.site.co.uk/controller/method works fine but

 

www.site.co.uk/admin/controller/method breaks

 

However www.site.co.uk/admin works fine.

 

Admin is a folder that exists.

 

My .htaccess looks like this 

RewriteEngine On
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ /index.php?id=$1 [L]

Nothing fancy there.

 

So what I have done is to add this same .htaccess file to the admin folder in the hopes that it would work. It hasn't. 

When you go to this page it just breaks because the first level doesn't see it as a controller and so fails.

 

What can I do to make this work. Can I add something to the htaccess in the root to handle it.

 

Thanks in advance

Edited by Lyleyboy
  • Solution

Ok, I've fixed this now.

All I needed to do is add the subfolder into the script inside the admin folder.

RewriteEngine On
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ /admin/index.php?id=$1 [L]
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.