0

I recently taken over a Drupal site to maintain and work on the design bit. I'm having an issue where if I enter a page on my site without the www prefix, I get directed to the front page. You should of course end up on the correct page anyway, maybe with the www prefix added.

I'm checking the .htaccess file and there i noticed this part:

 # If your site can be accessed both with and without the 'www.' prefix, you
 # can use one of the following settings to redirect users to your preferred
 # URL, either WITH or WITHOUT the 'www.' prefix. Choose ONLY one option:
 #
 # To redirect all users to access the site WITH the 'www.' prefix,
 # (http://example.com/... will be redirected to http://www.example.com/...)
 # uncomment the following:
 RewriteCond %{HTTP_HOST} !^www\. [NC]
 RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
 #
 # To redirect all users to access the site WITHOUT the 'www.' prefix,
 # (http://www.example.com/... will be redirected to http://example.com/...)
 # uncomment the following:
 # RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
 # RewriteRule ^ http://%1%{REQUEST_URI} [L,R=301]

As you can see I did comment out the first two rows so I thought this would correct this issue, but no, I get no change at all. Anyone got any idea about what could be wrong?

I also noticed this lines, which mentions a index.php redirect. But I can't really understand if this causes my problem.

 # Pass all requests not referring directly to files in the filesystem to
 # index.php. Clean URLs are handled in drupal_environment_initialize().
 # RewriteCond %{REQUEST_FILENAME} !-f
 # RewriteCond %{REQUEST_FILENAME} !-d
 # RewriteCond %{REQUEST_URI} !=/favicon.ico
 # RewriteRule ^ index.php [L]

There seems to be no 404 page but every wrong adress get redirected to the front page.

0
1

Try using this old method

RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]

Replace example with your domain name.

Still if you have the problem check your Redirects in Hosting Control Panel or you can contact them to support this.

1
  • Thanks for your input. Turns out some kind of alias had to be turned on in the server settings. I didn't do it myself otherwise I would have posted the solution here.
    – Johan Dahl
    May 23 '13 at 13:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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