I want to turn this Lighttpd mod_rewrite to apache rewrite code.

$HTTP["host"] =~ "^(i\.ylar\.se|puush\.me)$" {
    server.document-root = "/var/www/servers/i.ylar.se/"
    url.rewrite-once = (
            "^/api/up" => "/upload.php",
            "^/([a-zA-Z0-9]+)$" => "/view.php?image=$1"

Thanks for helping!


You probably need more than just a rewrite here...

Something like this might do it:

NameVirtualHost *:80
<VirtualHost *:80>
    ServerName   i.ylar.se
    ServerAlias  puush.me

    DocumentRoot /var/www/servers/i.ylar.se

    RewriteEngine On

    RewriteRule ^/api/up               /upload.php [L]
    RewriteRule ^/([a-zA-Z0-9]+)$     /view.php?image=$1

  • It seems like the VirtualHost part giving me the Error 500 Internal Server Error. I will check with my webhost if vhost is allowed/active? – Ylar Apr 1 '13 at 15:22
  • Now I see, I can't edit the vhost settings myself.. – Ylar Apr 1 '13 at 15:31
  • So you can't edit your server config? You're limited to what you can put in a .htaccess file? In that case you can add the rewriterules, but you can't define virtualhosts. – Krist van Besien Apr 2 '13 at 3:42
  • I contacted the support and got the answer that I could do it in the control panel. But the rewrite stuff doesn't seem to work. – Ylar Apr 2 '13 at 14:45
  • IF the rewrite doesn't work the first thing to do is to enable rewritelog. That way you'll see what goes on. You are putting the in a .htaccess file? If so you probably want rules that don't start with /. – Krist van Besien Apr 2 '13 at 15:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.