Apache URL Rewrite for Subdomain

275 views Asked by At

I'm trying to achieve the following:

An HTTP request made to subdomain.domain.com/some/path should be rewritten to domain.com/subdomain/api.php?__route__=some/path.

This is the requirement in order for the Epiphany library to function and properly process RESTful API calls. My website is currently hosted on GoDaddy and I have setup subdomain.domain.com to point to domain.com/subdomain using the GoDaddy web interface. I have placed the following text in the .htaccess file under the subdomain directory:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\?*$ api.php?__route__=/$1 [L,QSA]

I'm getting the standard 500 Internal Server Error when I try to make any calls to the RESTful API.

Unfortunately, I have to wait several hours before GoDaddy gives me access to any Apache log files. Any ideas why this isn't working?

EDIT

In order to clarify, I want the following rewriting to take place:

internal.ledworld-me.com/some/path => ledworld-me.com/internal/api.php?__route__=/some/path

Right now, GoDaddy is being used to map internal.ledworld-me.com to ledworld-me.com/internal. I'm starting to think I should remove the mapping from the GoDaddy side and rely solely on mod_rewrite in order to achieve this.

1

There are 1 answers

14
anubhava On

Put this code in your DOCUMENT_ROOT/internal/.htaccess file:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ api.php?__route__=/$1 [L,QSA]