HHVM - Rewrite rules for clean URLS
Asked Answered
D

1

6

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

Dao answered 17/2, 2014 at 6:20 Comment(1)
I have written an answer to this issue (which I have manually tested myself, and works). If it solves your issue, please select it as the answer, and if not, please explain your issue further.Brunswick
B
1

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 .

Brunswick answered 22/2, 2014 at 4:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.