3

I have added these lines in my 000-default virtual host file:

Alias /antoniocs/project "/home/antoniocs/www/project"
<Directory "/home/antoniocs/www/project">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
</Directory>

/home/antoniocs/www/project Contains a drupal website

If I go to:

localhost/antoniocs/project

This works out fine. I see everything perfectly. But when I try to click on a link that takes me, for example, to:

localhost/antoniocs/project/category

I get this error:

Not Found

The requested URL /home/antoniocs/www/project/index.php was not found on this server.

Is this not processing the .htaccess that is in the project folder? What am I doing wrong???

NOTE: I also find it strange that it's giving me a file path and not an url path

Running on Apache 2.2.16 (with mod rewrite) Ubuntu 10.10 php 5.3.3-1ubuntu9.1

EXTRA NOTE: For those that don't know drupals htaccess, it redirects everything to index.php?q=$1

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_URI} !=/favicon.ico

RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

4 Answers 4

7

I know this is a very old post but I thought this information I found on another StackExchange site might be of assistance.

When using an alias in your apache configuration you also need to use RewriteBase in your .htaccess file that's the same as the alias.

Alias /antoniocs/project "/home/antoniocs/www/project"
<Directory "/home/antoniocs/www/project">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
</Directory>

Requires that you include...

RewriteEngine On    
RewriteBase /antoniocs/project

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

I actually noticed it on a project because there was a rewrite going on with images/js/css and all my supplemental files were not loading.

2
  • Thank you Vagari. You saved me. I was experiencing a similar issue with cakephp 3.0. I was stuck for a week on it. I had to add RewriteBase to my .htaccess file in my app directory and in my webroot directory. Thx again.
    – Joe C
    Sep 6, 2016 at 15:24
  • This is the right answer.
    – Adam
    Nov 15, 2019 at 18:53
4

It sounds like a rewrite is taking place in the wrong location. For example, the webserver is trying to find the URL /home/antoniocs/www/project/index.php instead of the local file by the same path. Perhaps check the Drupal installation itself? You can check what the server thinks by looking at the requests for redirection using something like curl:

curl -I http://localhost/antoniocs/project/category

See if code 301 or 302 is returned, and that may help narrow down the problem. E.g.:

$ curl -I http://www.outflux.net/blog
HTTP/1.1 301 Moved Permanently
...
Location: http://www.outflux.net/blog/
1
  • The code returned is 404 :(
    – AntonioCS
    Nov 10, 2010 at 10:50
1

Alternatively you can also enable userdir module of apache. So that you don't have to create an alias to access the codes that resides in your home directory

sudo a2enmod userdir
cd ~
mkdir public_html
sudo /etc/init.d/apache2 restart

Put your code under this public_html and you can access it by http://localhost/~username or http://ipaddress/~username (for example: http://localhost/~aneesh)

You can change the directory name(public_html) by editing the conf file /etc/apache2/mods-enabled/userdir.conf

3
  • Thanks for this tip. I edited the userdir.conf and changed public_html to www but apache does not seem to reload the module configurations. Do I need to disable and enable the module for the new configurations to take effect? Also I tried putting a php file in the public_html (just to test it) and it sent me the file instead of running the php file
    – AntonioCS
    Nov 10, 2010 at 11:18
  • Ok I figured out what the problem was I forgot to change the UserDir. I keep having the same problem with clean urls, apparently the .htaccess is not being read
    – AntonioCS
    Nov 10, 2010 at 11:32
  • i assume that you are running php. Just have a look at /etc/apache2/mods-enabled/php5.conf. and comment the following section if it is not already done. <IfModule mod_userdir.c> <Directory /home/*/public_html> php_admin_value engine Off </Directory> </IfModule> </IfModule>
    – aneeshep
    Nov 22, 2010 at 6:25
1

See if anything here can help: https://drupal.org/node/163915, your problem may have something to do with the AllowOverride statement in; /etc/apache2/sites-available/default

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.