I have my Drupal installation in a subfolder and it's working ok, but there's one problem. New images can't be generated from image styles unless clean urls are turned off.

This is my .htaccess in the root:

Options -Indexes
RewriteEngine on
Options +FollowSymLinks
RewriteBase /
# Redirect all user to without WWW
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [L,R=301]

RewriteCond %{REQUEST_URI} ^.*\.(jpg|jpeg|gif|png|css|js|pl|txt)$
RewriteCond %{REQUEST_URI} !^/drupal/
RewriteRule ^(.*)$ /drupal/$1 [L,QSA]

#url 's
RewriteCond %{REQUEST_URI} !^/drupal
RewriteRule ^(.*)$ /drupal/index.php?q=$1 [L,QSA]

The htaccess in drupals folder is just as normal, just uncommented RewriteBase /drupal.

I understand what the problem is, the files are redirected directly to where they are, not going through Drupals system, which becomes the case when clean urls are turned off. But this is the only version of a htaccess file that works, and I've tried several. If I rewrite the files to /drupal/index.php?q=$1 images in the stylesheet and the logo and other images like that aren't displayed.

Would appreciate any help!

1 Answer 1


The ultimate goal here is to get any request to the base domain (http://www.example.com) redirected the drupal subdir (http://www.example.com/drupal), correct? Why not just remap everything to the subdir and let Drupal handle the www. prefix and clean-url mapping?

RewriteCond %{REQUEST_URI} !^/drupal
RewriteRule ^(.*)$ /drupal/$1 [L,R=301]
  • Thanks. This works, but this code adds to subfolder to the url and I would prefer to have the name of the subfolder not showing in the url. Changing [L,R=301] to [L] or [L,QSA] doesn't add the subfolder name to the url, but then Drupal gives me a 404 error, so that's not quite what I wanted...
    – Frida
    Commented Apr 29, 2015 at 11:50
  • Turned out the 404 error was because of something with Drupals cache. I ended up useing the code from here: stackoverflow.com/questions/21520794/…
    – Frida
    Commented Apr 29, 2015 at 12:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.