1

I have a copy of my website at localhost at:

/var/www/vhosts/mysite.com/httpdocs

This is my /etc/apache2/sites-available/mysite

<VirtualHost *:80>
        ServerAdmin webmaster@localhost

        DocumentRoot /var/www/vhosts/mysite.com/httpdocs
        <Directory />
                Options FollowSymLinks
                AllowOverride All
        </Directory>
        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog ${APACHE_LOG_DIR}/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

</VirtualHost>

I've copied htaccess.txt to .htaccess. When I activate friendly URL and URL rewriting, I get 404 errors.

I've uncommented this lines in .htaccess, but still does not work:

Options +FollowSymLinks
RewriteEngine On
RewriteBase /

I also tried to change rewritebase to

RewriteBase /mysite

with no luck.

What I'm doing wrong?

miquel
  • 379
  • 7
  • 17

2 Answers2

1

No sure if this is the issue you are experiencing, but I have experienced that rewriting does not work well on "localhost". Try and change your hosts file to say

127.0.0.1     mysite.local

And then access it on that url.

Not sure if that will work but it is worth a try.

Søren Beck Jensen
  • 1,676
  • 1
  • 12
  • 22
  • Hi Søren. It's still not working. I have another site at localhost (pure PHP) and URL rewriting is working fine. Thanks anyway – miquel Sep 27 '12 at 17:40
1

Solved! I had a conflict with different entries in /etc/apache2/sites-available. When I create a new site at localhost, I copy default to mysite, and modify the mysite file to point to it's DocumentRoot. I don't know exactly why, but if I disable default site:

sudo a2dissite default

it works.

Maybe this does'nt solve the question, but I prefer to issue another question more specific to this problem, because I've tested and it's related to different sites enabled and one or more with RewriteEngine enabled.

miquel
  • 379
  • 7
  • 17