i'm having trouble with the mod_rewrite rules in my .htaccess file on a site5 account.

the front page works fine, but other pages are loading incorrectly.

if someone goes to www.mysite.org/node/10 the page loads, but the links on the page assume that /node is the base directory. for example, where the html reads "< img src="files/democratica_logo.png" />" the browser tries pulling up " http://www.mysite.org/node/files/democratica_logo.png" instead of "http://www.mysite.org/files/democratica_logo.png".

The relevant section of my .htaccess file reads:

    # Various rewrite rules.
    <IfModule mod_rewrite.c>
      RewriteEngine on

      # Modify the RewriteBase if you are using Drupal in a subdirectory and
      # the rewrite rules are not working properly.
      RewriteBase /ypfp/

      # Rewrite current-style URLs of the form 'index.php?q=x'.
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      # RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
      RewriteRule ^(.*)$ /index.php?q=$1 [L,QSA]
    </IfModule>

Anyone know what the solution could be?

Thanks!

Comments

terotil’s picture

Are all the links broken that way? Drupal-generated links too, menu and stuff? Hardwired links in node content could just be plain broken.

piersonr’s picture

I'm now thinking the problem is that there is no starting slashes on urls, including drupal generated ones.

It seems like this was an issue as far back as 2004 up until late '06, and was patched into 4.7. Is there any way to include starting slashes using a mod_rewrite, or some other solution that doesn't require an upgrade? (I have custom modules that I'm a little hesitant about updating)

piersonr’s picture

I realized that this problem was caused by not using $base_url in settings.php ...

I added my website URL into base url and the problem was fixed.

agateb’s picture

I am having the same problem after enabling mod_rewrite and I cannot immediately upgrade Drupal to fix this. All my relative links are now been preceded by 'node' and are not been displayed. The way I've found to get around this is including '../' in my paths but I have too many links to go and change this way. My settings.php file already has $base_url set. Here is the relevant snippet of my .htaccess file:

  RewriteBase /
 

  # Rewrite current-style URLs of the form 'index.php?q=x'.
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
Rebecca@category.greenash.net.au’s picture

Is there any particular reason you un-commented RewriteBase? Because you shouldn't have to. You only use that if it's acting squirrelly. I don't use it. It's stayed commented out for over a year and a couple of upgrades.

Try putting the # back in that line and see if it helps.