0

I am having trouble getting URL rewriting to work. I have tried everything I can think of. I have checked all possible places where AllowOverride is set to None and changed it to All. mod_rewrite is itself enabled, I have restarted Apache several times. My vhost looks as below

<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName www.abc.ac.uk
    ServerAlias www.abc.ac.uk
    DocumentRoot /var/www/testRewrite

    RewriteEngine ON
    RewriteRule ^/test /TestMe.html

    <Directory /var/www/testRewrite>
            Options Indexes FollowSymLinks
            AllowOverride All
            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 debug
    RewriteLogLevel 8
    RewriteLog /var/log/rewrite.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
  </VirtualHost>

The request does not get forwarded to TestMe.html. The rewrite.log is empty. What am I doing wrong and how could I debug this?

2
  • What ends up in your access.log? Does anything else write to that log? Do you have any other vhosts?
    – Ladadadada
    Feb 27, 2013 at 21:53
  • I have several other virtual hosts, but they all have their own files. Only apache writes to that log and for this request I get HTTP/1.1" 404 506
    – user10211
    Feb 27, 2013 at 22:29

2 Answers 2

0

Have you tried putting the rewrite rules inside the Directory section of the VirtualHost?

You might also try specifying a RewriteBase

1
  • I tried that, but it does not work.
    – user10211
    Feb 28, 2013 at 6:23
0

Is this within a .htaccess file? If so, you shouldn't have the initial / in the RewriteRule. That one's bitten me more than a few times.

If it's not, the first step to debugging mod_rewrite is to turn on logging. Exactly how you do this depends on if you're running apache 2.4 or one of the older ones.

You might also find some help in this list of common mod_rewrite question.

1
  • This is not within a .htaccess file. It sits in sites-available in /etc/apache2. The logging is on but besides 404, I do not get anything in the access log, the rewrite log is empty.
    – user10211
    Feb 28, 2013 at 9:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .