I have links like this - http://example.com/index.php?q=about
and I want to make them look like this - http://example.com/about
Currently I am using the Rewrite Rules
VirtualHost {
* {
Pattern = .*
RewriteRules {
dirindex {
pattern = (.*)/$
to = index.php/$1
qsa = true
}
}
}
}
If I visit http://example.com/about I am getting a 404 File Not Found
I am doing this for Drupal. Guidelines for clean urls : https://drupal.org/getting-started/clean-urls
The issue can be resolved using the VirtualHost, but the server module of HHVM is depreciated now, and you are encouraged to use fastcgi over apache/nginx. I will put an answer for VirtualHost, but if needed, can update with an nginx alternative.
First, make sure that your SourceRoot is correct:
Server {
Port = 9000
SourceRoot = /home/myuser/www
DefaultDocument = index.php
}
Now, for the rule, this should potentially work:
VirtualHost {
* {
Pattern = .*
RewriteRules {
* {
pattern = (.*)$
to = index.php/$1
qsa = true
}
}
}
}
If you want the query to work exactly as you are intending it to, replace the inner pattern with this:
* {
pattern = /(.*)
to = index.php?q=$1
qsa = true
}
I have tested these both, and they work well. If you are still facing an issue, the issue may be potentially with your setup. Make sure you enable Error and Access logging .
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With