So here is the situation
- Apache2 running in Ubuntu
- Multiple hosts in /var/www
- Two sites are drupal based

I have been reading about adding in 000-default or www.example.com.conf
AllowOverride All
Option +Indexes ... all that
but nothing works. Whenever I go to test for clean urls I get page cannot be found. I tried adding .htacess in /var/www/example.com but that didn't do anything either, it actually made it worst as nothing as coming up anymore...even when going to www.example.com I was getting 403 Permission Denied.

In the apache2 folder I have sites-available and sites-enabled, and it looks like the conf files are linked from one folder to the other, so it doesn't matter where I make the changes.
In /var/www there is a folder for each website I have as each domain name points to a particular folder (i.e. www.example.com points to /var/www/example)

I really don't know where to go from here and I would appreciate any help on this.

Thank you.

Comments

arhak’s picture

do you have mod_rewrite enabled?

root# a2enmod rewrite

krager83’s picture

Rewrite was already enabled

# a2enmod rewrite
This module is already enabled!

devenderdagar’s picture

Hi Ciprian

You can enable mod rewrite using .htaccess file. google how to enable mod rewrite using .htaccess and then you can find somt thing sure. if you still have some issues let me know I will google for you.

Cheers

krager83’s picture

The module is already enabled so should I still enable it through .htaccess?

arhak’s picture

no, the .htaccess packaged with Drupal already takes care of it RewriteEngine On, etc, etc

krager83’s picture

Another thing to add to this...
If I create an .htaccess file and put in:

# Various rewrite rules.

RewriteEngine on

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

# Rewrite old-style URLs of the form 'node.php?id=x'.
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteCond %{QUERY_STRING} ^id=([^&]+)$
#RewriteRule node.php index.php?q=node/view/%1 [L]

# Rewrite old-style URLs of the form 'module.php?mod=x'.
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteCond %{QUERY_STRING} ^mod=([^&]+)$
#RewriteRule module.php index.php?q=%1 [L]

# 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] #I put the slash in front on index as someone suggested that they got it going by putting it

my entire site goes into 403 Forbidden You don't have permission to access / on this server.

arhak’s picture

searched Google for site:drupal.org "clean URLs" and the first hits are documentation pages at drupal.org

- Clean URLs
- Setting up Clean URLs
- Clean URLs not working? Check your .htaccess file!
- etc

krager83’s picture

I've tried all those links and as soon as I put in .htaccess I get 403 Forbidden
Here is my .htaccess file:

# Various rewrite rules.

RewriteEngine on

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

# Rewrite old-style URLs of the form 'node.php?id=x'.
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteCond %{QUERY_STRING} ^id=([^&]+)$
#RewriteRule node.php index.php?q=node/view/%1 [L]

# Rewrite old-style URLs of the form 'module.php?mod=x'.
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteCond %{QUERY_STRING} ^mod=([^&]+)$
#RewriteRule module.php index.php?q=%1 [L]

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

The RewriteRule had index.php/?q=$1 before, but looking at what shows up when I go to the website, I didn't see index.php showing up. All I see is www.example.com/?q=about or whatever other page I'm on. So I took index.php out to give it a shot.

Here is the www.example.com.conf file (which is located in /etc/apache2/sites-enabled):

DocumentRoot /var/www/example/
ServerName www.example.com

AllowOverride All

Options Indexes

Thank you for helping me with this.

arhak’s picture

krager83’s picture

Got it to work... a friend of mine pointed out that I should put the following in my .htaccess file:
Order allow,deny

# Don't show directory listings for URLs which map to a directory.
Options -Indexes
# Follow symbolic links in this directory.
Options +FollowSymLinks
# Set the default handler.
DirectoryIndex index.php index.html index.htm

After adding that, the 403 Forbidden went away and clean urls passed the test and was able to enable it.

Thank you for your help.

arhak’s picture

but Drupal comes with that in its .htaccess

you should preserve the .htaccess file that comes with Drupal
how did you miss it?

arhak’s picture

EDIT: double post removed