Page 1 of 1

Cannot access /admin after enabling mod_rewrite for "pretty" URL's

Posted: Thu Jan 15, 2009 11:06 am
by mahoomeister
Hi,

I'm new to CMS Made Simple and I'm running cmsmadesimple-1.5.1. My site was working perfectly and still is, but with one small problem. After enabling mod_rewrite to implement "pretty URL's" I can no longer access my admin section. When I browse to mydomain.com/admin I'm getting the custom error page I created.

I could access my admin section prior to enabling mod_rewrite and i've disabled it and can access the admin section again - so the problem is definitely to do with mod_rewrite. I've included my entire URL setting below.

#------------
#URL Settings
#------------

#Show mod_rewrite URLs in the menu? You must enable 'use_hierarchy' for this to work for modules
$config['assume_mod_rewrite'] = true;

#Extension to use if you're using mod_rewrite for pretty URLs.
$config['page_extension'] = '.html';

#If you don't use mod_rewrite, then would you like to use the built-in
#pretty url mechanism?  This will not work with IIS and the {metadata} tag
#should be in all of your templates before enabling.

$config['internal_pretty_urls'] = false;

#If you're using the internal pretty url mechanism or mod_rewrite, would you like to
#show urls in their hierarchy?  (ex. http://www.mysite.com/parent/parent/childpage)
$config['use_hierarchy'] = true;

#If using none of the above options, what should we be using for the query string
#variable?  (ex. http://www.mysite.com/index.php?page=somecontent)
$config['query_var'] = 'page';

Do I need to make some changes to the .htaccess file inside /admin? I'm guessing the solution is something small and simple! Any help with solving this issue is much appreciated. Thanks in advance

- Mahoo

Re: Cannot access /admin after enabling mod_rewrite for "pretty" URL's

Posted: Thu Jan 15, 2009 4:22 pm
by mahoomeister
*UPDATE*

I have tried a few things and have pinned the problem down to the .htaccess file. Something that I neglected to mention was that I currently have the /admin directory password protected - put in place using CPanel (creates both .htaccess files in root and /admin).

With mod_rewrite enabled, here are my .htaccess files:

.htaccess file in root

Code: Select all

AuthUserFile "/home/mydomain/.htpasswds/public_html/mydomain/passwd"
AuthName "Authorised Users Only!"

RewriteEngine on
RewriteCond %{HTTP_HOST} ^mydomain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.mydomain.com$
RewriteRule ^start$ "http\:\/\/mydomain\.com\" [R=301,L]

Options +FollowSymLinks
RewriteEngine on
RewriteBase /

# 301 Redirect all requests that don't contain a dot or trailing slash to
# include a trailing slash
# RewriteCond %{REQUEST_URI} !/$
# RewriteCond %{REQUEST_URI} !\.
# RewriteRule ^(.*) %{REQUEST_URI}/ [R=301,L]

# Rewrites urls in the form of /parent/child/
# but only rewrites if the requested URL is not a file or directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+).html$ index.php?page=$1 [QSA] 
.htaccess file in /admin

Code: Select all

AuthType Basic
AuthName "Administration"
require valid-user
AuthUserFile "/home/mydomain/.htpasswds/public_html/mydomain/admin/passwd"
Note: I have also tried sticking in the content of the .htaccess file located in root in the one located in /admin - no luck.

Prior to enabling mod_rewrite I was prompted for a username and password when I browsed to mydomain.com/admin but after enabling mod_rewrite I was immediately presented with my custom error page. When I removed the password protection this I was able to access the /admin directory but obviously wasn't prompted for a password before the admin login page was displayed.

So, I suppose (could be wrong!) my problem now is how to get mod_rewrite to work correctly with an existing .htaccess file. Any takers? As always, any help is much appreciated.

- Mahoo

Re: Cannot access /admin after enabling mod_rewrite for "pretty" URL's

Posted: Thu Jan 15, 2009 11:26 pm
by Pierre M.
Hello,

have you tried the provided .htaccess sample ?

Pierre M.

Re: Cannot access /admin after enabling mod_rewrite for "pretty" URL's

Posted: Wed Jan 21, 2009 10:28 am
by mahoomeister
Hi Pierre,

Sorry, I have been offline for a couple of days. Thank you for your response.
have you tried the provided .htaccess sample ?
Apologies in advance, but I'm not sure what you mean. What provided .htacccess sample are you referring to?

- Mahoo

Re: Cannot access /admin after enabling mod_rewrite for "pretty" URL's

Posted: Wed Jan 21, 2009 3:28 pm
by tyman00

Re: Cannot access /admin after enabling mod_rewrite for "pretty" URL's

Posted: Wed Jan 21, 2009 8:54 pm
by Pierre M.
The one in the /doc directory :-)

Re: Cannot access /admin after enabling mod_rewrite for "pretty" URL's

Posted: Thu Jan 22, 2009 1:12 pm
by mahoomeister
Hi tyman00 and Pierre,

Thanks for pointing that out guys. Em, I've already said that I had included that content in my .htaccess file! Jeez, I know my posts are long - but did you guys even read them :) hehe

I need to get my mod_rewrite .htaccess file to work with a password protected directory. See *UPDATE*

- Mahoo

Re: Cannot access /admin after enabling mod_rewrite for "pretty" URL's

Posted: Fri Jan 23, 2009 7:58 pm
by Pierre M.
Try to put your rewriting .htaccess in the main directory and the password protecting .htaccess in the /admin directory under it.

Pierre M.

Re: Cannot access /admin after enabling mod_rewrite for "pretty" URL's

Posted: Fri May 29, 2009 4:55 pm
by clc
I had the same problem, and found the solution here:

http://forum.cmsmadesimple.org/index.ph ... 659.0.html

Creating a blank file named 401.shtml in the public_html folder fixed it.  Hope this helps...