Jump to content

Rewrite even if the Directory Exists.


Jumpy09

Recommended Posts

Alright so I have successfully set up a Mod Rewrite that gives clean URLS to everything on the normal scope.  This deals with files located in the root directory, but the way I am doing admin pages I am having a bit of a problem getting the rewrite to work right with it.

 

Alright so I call the admin page through http://127.0.0.1/admin/

 

I want this URL to go to http://127.0.0.1/admin.php which will call files from within the directory of /Admin/

 

This is what I have in regards to that.

 

RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^admin/$ admin.php

 

From what I understand this should rewrite even if the directory exists, but since I have -Indexes I am receiving a 403 Error ( Access Forbidden ) and if I have +Indexes I get the Admin folder.

 

Is there anything I am missing?

 

This is done on an XAMPP 1.7.7 Setup

Apache 2.2.21 ( Win32 )

PHP 5.3.8

 

Edit: The only thing I can think of is to place a .htaccess file in the directory, but shouldn't the main .htaccess file catch the request even before it gets that far?

 

Edit #2: For my local server I am working in a Sub-Folder so technically it is http://127.0.0.1/Site/admin/ and the rewrite base is /Site.  The .htaccess file is located in the /Site/ sub-folder.  That slipped my mind.  I moved the .htaccess file to the Root Directory but I think I would have to rewrite the rewrite items to make it even rewrite correctly.

Link to comment
https://forums.phpfreaks.com/topic/253434-rewrite-even-if-the-directory-exists/
Share on other sites

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.