Jump to content

htaccess RewriteRule & htpasswd Clash


Manny

Recommended Posts

I'm currently trying to build an admin CMS and in order to hide querystrings, I have used htaccess to rewrite the URLs into something a little more user friendly. The rewrites work perfectly. However, I want to use htpasswd to protect the directory from outsiders. The code I have at the moment can be found below.

AuthName "Restricted Area"AuthType BasicAuthUserFile /root/to/fileAuthGroupFile /dev/nullrequire valid-user RewriteEngine onRewriteBase /directory/ RewriteRule ^([a-z0-9-]+)/?$ index.php?query=$1 [L]RewriteRule ^([a-z0-9-]+)/([a-z0-9-]+).php$ index.php?query=$1&string=$2 [L]

When I try to use the admin section, I am being presented with this message:[an error occurred while processing this directive] If I remove the first five lines of the code, the CMS works fine, but is not password protected. If I remove everything from line 6 onwards, the htpasswd script kicks in and you are asked to log in with a username and password. What is causing the clash and how can I get the system to work as it should, but with htpasswd protection enabled?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...