0

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!

Ylar
  • 3
  • 2

1 Answers1

2

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

</VirtualHost>
Krist van Besien
  • 1,832
  • 13
  • 16
  • 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 01 '13 at 15:22
  • Now I see, I can't edit the vhost settings myself.. – Ylar Apr 01 '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 02 '13 at 03: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 02 '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 02 '13 at 15:27
  • Yes, I'm using htaccess. I will try without the slashes. – Ylar Apr 02 '13 at 15:38