After quite some trial and error, I managed to configure .htaccess to work the way I want. Only to find out that I've lost access to the admin panel. Reverting to the old situation doesn't seem to help.
If I go to http://mydomain.com/drupal/?q=admin/login I can see in the tab title "Access denied". I don't get any login screen.
Here's what I did:
1) Cloned my drupal install to subfolder /drupal to keep the root tidy (after this point I still have been able to modify the site using admin access).
2) modified drupal/sites/default/settings.php to have $base_url = 'http://mydomain.com';
3) updated .htaccess in the root directory to have it refer invisibly to the /drupal subfolder and to redirect all www.-requests to http://domain.com
Options +FollowSymlinks
RewriteEngine on
# .htaccess primary domain to subfolder redirect
# also updated ../drupal/sites/default/settings.php with $base_url = 'http://mydomain.com'; (first make folder writeable)
# First redirect any file requests without '/drupal/' in the URL to the subfolder /drupal/
RewriteCond %{HTTP_HOST} !^(www.)?mydomain.com/admin$
RewriteCond %{HTTP_HOST} ^(www.)?mydomain.com$
RewriteCond %{REQUEST_URI} !^/drupal/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /drupal/$1
# Then redirect http://www.mydomain.com to http://mydomain.com
RewriteCond %{HTTP_HOST} ^www\.mydomain\.com$ [NC]
RewriteRule ^(.*)$ http://mydomain.com/$1 [R=301,NC]
# Lastly refer either www.mydomain.com (shouldn't be the case anymore because of rule above) or mydomain.com to ../drupal/index.php
RewriteCond %{HTTP_HOST} !^(www.)?mydomain.com/admin$
RewriteCond %{HTTP_HOST} ^(www.)?mydomain.com$
RewriteRule ^(/)?$ drupal/index.php
I tried reverting to the old situation (step 2, settings.php and step 3 .htaccess file).
I tried truncating the cache tables through phpMyAdmin.
But to no avail.
Who can help me regain access to drupal?
Comments
problem is still actual
I am still not able to get to a login screen or access the admin panel in any other way.
If anyone can be of help, I'd appreciate it.
=-=
http://mydomain.com/drupal/?q=admin/login isn't the correct path to the login form.
http://mydomain.com/drupal/?q=user/login is the correct path.
Thank you for your reply VM.
Thank you for your reply VM.
If I go to this URL however, I get a tab named 'User account | [sitename]'. It shows the uppermost header and the footer, but any content in between is omitted.
And most importantly, I don't have any means to fill in admin credentials!
=-=
sounds like some errant CSS could be hiding the fields on the login form. Inspect CSS. if necessary switch theme to a core theme and test.
almost there
You are 100% right!
I commented out a section that I don't want to display on my site, but it also contains the login fields. I hope I can change the location of the login block in the admin panel, but for that, I first have to solve another problem:
Whenever I click any button in the admin panel, e.g. "Appearance", the first letter is stripped off and I get a page saying:
I tried some minor changes in the .htaccess file, but couldn't figure out which line is causing the problem (supposing it is indeed the .htaccess file that is at fault).
=-=
I'd grab a copy of the default .htaccess and test. If .htaccess isn't the problem my first inclination would be that there is something awry with the menus.
It seems that the problem is
It seems that the problem is in .htaccess.
If I use the original .htaccess I still have to insert /drupal/ to refer to the installation in the subfolder, but then it works.
=-=
Add your .htaccess customizations one at a time until the problem reveals itself again. You will then know which is problematic.
*SOLVED*
Problem seems to be solved. I hope it could be done easier, but it's just the way it is.
Here's what went wrong:
Because I use a very simple website in the CorporateClean theme, I decided to only use the banner option in the header, so I commented out the 'content' pages. This is perfect for displaying my website, but when accessing the admin panel, all the content (including login fields) will not be displayed.
Here's what I adjusted:
1) Add the following redirect to .htaccess to never again forget the URL from where I can login:
2) Display the 'content' section only when accessing the admin sections by enveloping it with:
This makes sure that no content pages are shown when normal users visit, but it will be shown when logging in or after logging in to access admin overlays.
3) I changed $base_url in sites/default/settings.php to 'http://domain.com/drupal_installation_directory'.
One manual I read discouraged changing the $base_url to 'http://domain.com/drupal_installation_directory' (and leave it at 'http://domain.com'). This however, resulted in admin pages not displaying well (the subdirectory was missing in the admin pages). And this was somehow also the cause of the disappearing first letter of pages (e.g. '/ppearence'), it wasn't in .htaccess after all.
Thanks a ton, VM!