Hello,
I am installing Drupal 7.x-dev on a shared host (bluehost) and wanted to set up a git repository in the public_html/ folder. Because I wanted some other sites with subdomains, I wanted to put the actual Drupal installation under the public_html/trunk/ directory. But I did not want my website to have the /trunk/ subdirectory in all of the URLs. I would then make public_html/ the root of my git repository.
The default .htaccess does not appropriately forward requests, and the overlay functionality doesn't work. I keep getting "page not found".
This is how I set up /public_html/.htaccess:
# Use PHP5 Single php.ini as default
AddHandler application/x-httpd-php5s .php
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_URI} !^/trunk/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /trunk/$1
RewriteCond %{HTTP_HOST} ^(www\.)?paperepiphany\.com$
RewriteRule ^(/)?$ trunk/index.php [L]
To fix this, I had to change /public_html/trunk/.htaccess (the .htaccess associated with the Drupal installation) to use the rule used in Drupal 6. Namely, change this:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^ index.php [L]
to this:
# ... same RewriteConds
RewriteRule ^(.*)$ index.php?q=$1 [L]
The other adjustment I made was to set $base_url="http://www.paperepiphany.com" in settings.php.
After making my changes, the site worked, but now the overlays just go to full page reloads instead of the nice AJAX-y overlays, which is a bummer.
I admit I'm not an expert in mod_rewrite, so if the original trunk/.htaccess file is correct, and I did something wrong in .htaccess, then what is the appropriate adjustment to make?
Even though the site does degrade gracefully wrt the overlays, I think it would be nice for the overlays to work even in this setup, because I don't think this is an unusual use case.
Comments
Comment #1
aaron commentedsetting component
Comment #2
Andrey Zakharov commentedSame issue with subfoldering, overlays and $_SERVER['REQUEST_URI'] :(
works for me
Comment #3
Jeff Burnz commentedSubscribing...
Comment #4
droplet commentedmove .htaccess to root dir and change
RewriteBase /SUB-DIR
Comment #5
desoi commentedAs described here, the problem appears to be in request_path (includes/bootstrap.inc)
http://drupal.org/node/1072874
Drupal 6 worked fine in a subdirectory with mod_rewrite, Drupal 7 does not (tested 7.7). It can work with Drupal 7 if the clean URL setting is turned off.
Comment #6
mikey_p commentedThis doesn't sound like a problem specific to the overlay module.
Comment #7
trevorbradley commentedSubscribing. Just hit this today. My D6 installs worked great in subdirectories with mod_rewrite. Drupal 7 won't even allow me to change pages or log out if $base_url is set. Works fine with $base_url unset (but with ugly URLs)
Also, verifying the change to core's .htaccess to:
RewriteRule ^(.*)$ index.php?q=$1 [L]
as described above works! EDIT: Although it appears to break the overlay.
Comment #8
nwolff commentedUsing drupal 7.8 the problem is still there. Applied the suggested change to the drupal/.htaccess and things seemed to work at first, but now:
- batch operations fail with an access denied error.
- user registration fails
---------------
When trying to debug I noticed:
- clean urls work. eg: http://mysite.com/node/1
- path aliases dont.
Comment #9
marcingy commentedThis is major at most
Comment #10
catchComment #11
wavesailor commentedcatch, you changed it to 8.x-dev.
Does this mean it will never get fixed in 7.x?
This is a real problem for me
Comment #12
magnusk commentedI believe it relates to #757506: $base_url broken with .htaccess RewriteRule. I thus patch includes/bootstrap.inc whenever a new Drupal 7.x is released.
Comment #13
catch@wavesailor, no. See the tag I added at the same time. Also http://drupal.org/node/767608
Comment #14
trevorbradley commented@magnusk. I've updated the patch at #757506 so that it applies to Drupal 7.9. Without editing my .htaccess and patching bootstrap.inc, I now have a working site in a subdirectory, aliased to believe it's the root, while not corrupting my URLs (previous patches that modified .htaccess would break things like batch operations or changing themes)
http://drupal.org/node/757506
Comment #15
catchLooks like #757506: $base_url broken with .htaccess RewriteRule may fix this, is the older issue, and has more useful information in it. So I'm marking this one as duplicate.