One of my webhosts uses Apache Rewrite for (sub-) domains. Without changing anything in .htaccess and settings.php the urls looked like:

http://subdomain.website.de/subfolder_of_webroot/

That worked fine - but I wanted to get rid of "subfolder_of_webroot" part of the url. So I uncommented .htacces with "RewriteBase /subfolder_of_webroot" and in settings.php i put "$base_url = 'http://subdomain.website.de'".
But then strangly the request part of the url was cut off strangly (example from log entries):

Type page not found
Location http://subdomain.website.de/admin/people
Referrer http://subdomain.website.de/
Message ple
Severity warning

(the ple comes from people)

I could get it done by changing a RewriteRule in .htaccess to the old drupal 6 way.

# RewriteRule ^ index.php [L]
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

So can anybody tell me why .htaccess changed that way in drupal 7?

Comments

heine’s picture

To prevent thorny URLencoding issues, Drupal 7 no longer needs a rewrite to a query string. Instead, drupal_environment_initialize and request_path parse the requrested uri.

Make the subdirectory the webroot for the vhost in question.

schomsko’s picture

i'll take a look at them.

Unluckily at this webhosting service i can not configure vhosts. It's all done by apache mod rewriting.

schomsko’s picture

To use Drupal 7 on a hoster that has no vhosts but does it all by url rewriting you got to use the old Drupal 6 query rewriting in .htaccess if you don't like to have the subfolder showing up in your url:
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
To problem is in http://api.drupal.org/api/function/request_path/7

  elseif (isset($_SERVER['REQUEST_URI'])) {
    // This is a request using a clean URL. Extract the path from REQUEST_URI.
    $request_path = strtok($_SERVER['REQUEST_URI'], '?');
    $base_path_len = strlen(rtrim(dirname($_SERVER['SCRIPT_NAME']), '\/'));
    // Unescape and strip $base_path prefix, leaving q without a leading slash.
    $path = substr(urldecode($request_path), $base_path_len + 1

it outputs in my case:
---------
Script Name: /drupal-7/index.php
request_uri= /admin/config
Request Path: /admin/config
Base Path Length: 9
Path: fig
---------
It would by helpfull to check if the REQUEST_URI starts with the path in SCRIPT_NAME, so that you do not have to trim the $request_path at all.

That should solve issues for people with "rewrite servers".