Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am trying to test a simple rewrite on my local apache server (ubuntu 11.10 Desktop)

Here is the virtual directory settings:

<VirtualHost magic.al:83>
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www/test/
    <Directory />
            Options FollowSymLinks
            AllowOverride all
    </Directory>
    <Directory /var/www/test/>
            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 /var/log/apache2/error.log

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


    CustomLog /var/log/apache2/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>

RewriteEngine on
RewriteRule ^page/([^/\.]+)/?$ index.html?page=$1 [L]
RewriteLog      "/var/log/apache2/rewrite.log"
RewriteLogLevel 9


</VirtualHost>

Here is the url:

http://magic.al:83/page/software

Here is the output in rewrite.log:

init rewrite engine with requested uri /page/software
applying pattern '^page/([^/\.]+)/?$' to uri '/page/software'
pass through /page/software

I cannot seem to get this right.

share|improve this question
    
I changed by added a / after the ^ RewriteRule ^/page/([^/\.]+)/?$ index.html?page=$1 [L] and now I get: rewrite '/page/software' -> 'index.html?page=software' - split uri=index.html?page=software -> uri=index.html, args=page=software; local path result: index.html - then Bad Request Your browser sent a request that this server could not understand. –  Kylea Mar 13 '12 at 14:04
    
One more added leading / to index.html?page=$1 –  Kylea Mar 13 '12 at 14:13
    
Here is the correct format: Needed leading "/" on RewriteRule for "page" and leading "/" on the target "index.html" RewriteEngine on RewriteRule ^/page/([^/\.]+)/?$ /index.html?page=$1 [L] RewriteLog "/var/log/apache2/rewrite.log" RewriteLogLevel 9 –  Kylea Mar 13 '12 at 14:15
    
well now, consider decreasing RewriteLogLevel unless you still need debugging –  m0ntassar Mar 13 '12 at 15:44
add comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.