Featured image of post Ubercart Quest: Clean URL for Drupal

Ubercart Quest: Clean URL for Drupal

Note: This post was created awhile back on another platform and I migrated to my current one.

Problem:

Product’s images are not showing

One possible cause mentioned in the Ubercart forum is that Clean URLs is not enabled.


Step 1: Enable mod_rewrite

Clean URLs requires mod_rewrite to be enabled

(Note: mod_rewrite is an Apache 2 module)

To check if mod_rewrite is enabled, run the following command:

1
/usr/sbin/apache2ctl -M

Look for:

1
rewrite_module

This is the mod_rewrite module required for Clean URLs.


Step 2: Enable mod_rewrite if it’s not enabled

To enable mod_rewrite, run:

1
sudo /usr/sbin/a2enmod rewrite

After entering the command, you should see:

1
2
Enabling module rewrite.
Run '/etc/init.d/apache2 restart' to activate new configuration!

To disable mod_rewrite, use:

1
sudo /usr/sbin/a2dismod rewrite

After disabling, you should see:

1
2
Module rewrite disabled.
Run '/etc/init.d/apache2 restart' to activate new configuration!

Remember to restart Apache 2 after making changes:

1
sudo /etc/init.d/apache2 restart

Step 3: Check Your Apache 2 Configuration

(I’m an Apache 2 noob, so bear with me.)

In the /etc/apache2/sites-enabled folder, create a config file for your Drupal site.

Example file: /etc/apache2/sites-enabled/drupal.conf

Basic Configuration:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
<VirtualHost *:80>
    ServerName www.example.com
    DocumentRoot /var/www/drupal-6.13
    <Directory /var/www/drupal-6.13>
        Options FollowSymLinks
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

Enable Rewrite Rules

Add the following inside the <Directory> section:

1
2
3
4
5
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

Final Configuration:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
<VirtualHost *:80>
    ServerName www.example.com
    DocumentRoot /var/www/drupal-6.13
    <Directory /var/www/drupal-6.13>
        RewriteEngine on
        RewriteBase /
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
        Options FollowSymLinks
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

Restart Apache 2 again:

1
sudo /etc/init.d/apache2 restart

Step 4: Enable Clean URLs in Drupal

  1. Go to AdministerSite ConfigurationClean URLs

  2. You should see the following path:

    1
    
    home > administer > site configuration
    
  3. Enable Clean URLs.

Ta-da! 🎉 Now the product images should display correctly!


System Information:

Debian Lenny with Apache 2

For more information about mod_rewrite:
Apache module mod_rewrite

Resources:

comments powered by Disqus

Desiderata by Max Ehrmann

Go placidly amid the noise and the haste, and remember what peace there may be in silence. As far as possible without surrender be on good terms with all persons. Speak your truth quietly and clearly; and listen to others, even to the dull and the ignorant, they too have their story. Avoid loud and aggressive persons, they are vexations to the spirit.

If you compare yourself with others, you may become vain or bitter; for always there will be greater and lesser persons than yourself. Enjoy your achievements as well as your plans. Keep interested in your own career, however humble; it is a real possession in the changing fortunes of time.

Exercise caution in your business affairs, for the world is full of trickery. But let not this blind you to what virtue there is; many persons strive for high ideals, and everywhere life is full of heroism. Be yourself. Especially do not feign affection. Neither be cynical about love; for in the face of all aridity and disenchantment it is as perennial as the grass. Take kindly the counsel of the years, gracefully surrendering the things of youth.

Nurture strength of spirit to shield you in sudden misfortune. But do not distress yourself with dark imaginings. Many fears are born of fatigue and loneliness. Beyond a wholesome discipline, be gentle with yourself. You are a child of the universe, no less than the trees and the stars; you have a right to be here. And whether or not it is clear to you, no doubt the universe is unfolding as it should.

Therefore, be at peace with God, whatever you conceive Him to be. And whatever your labors and aspirations in the noisy confusion of life, keep peace in your soul. With all its sham, drudgery and broken dreams; it is still a beautiful world. Be cheerful.

Strive to be happy.

Built with Hugo
Theme Stack designed by Jimmy