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

aaron’s picture

Component: file system » overlay.module

setting component

Andrey Zakharov’s picture

Same issue with subfoldering, overlays and $_SERVER['REQUEST_URI'] :(

works for me

Jeff Burnz’s picture

Subscribing...

droplet’s picture

Category: bug » support

move .htaccess to root dir and change

RewriteBase /SUB-DIR

desoi’s picture

As 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.

mikey_p’s picture

Component: overlay.module » base system

This doesn't sound like a problem specific to the overlay module.

trevorbradley’s picture

Subscribing. 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.

nwolff’s picture

Priority: Major » Critical

Using 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.

marcingy’s picture

Version: 7.x-dev » 7.8
Category: support » bug
Priority: Normal » Major

This is major at most

catch’s picture

Version: 7.8 » 8.x-dev
Priority: Critical » Major
Issue tags: +Needs backport to D7
wavesailor’s picture

catch, 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

magnusk’s picture

I 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.

catch’s picture

@wavesailor, no. See the tag I added at the same time. Also http://drupal.org/node/767608

trevorbradley’s picture

@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

catch’s picture

Status: Active » Closed (duplicate)

Looks 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.