1

I need to redirect subdomain.example.com -> subdomain.example.com:32400/web

My current htaccess is:

Options -MultiViews +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^subdomain.example.com [NC]
RewriteRule (.*) http://subdomain.example.com:32400/web [R=301,L]

AuthUserFile /var/.htpasswd
AuthName Welcome
AuthType Basic

require user someone

IndexOptions +ShowForbidden
ErrorDocument 401 /error401.html
ErrorDocument 404 /errorGeneric.html
ErrorDocument 500 /errorGeneric.html

However I keep getting 500 Internal Server errors with the redirect enabled, if the redirect is not active then the .htaccess works fine

1
  • If you get 500 errors, check the Apache HTTPD log file and see what the error was. Apr 1, 2014 at 12:46

3 Answers 3

0

For simple cases, you don't need to use mod_rewrite. It might be sufficient to use mod_proxy instead; something like:

ProxyPass / http://subdomain.example.com:32400/web
ProxyPassReverse / http://subdomain.example.com:32400/web 

(untested)

0

Did you try the RewriteLog directive, with RewriteLogLevel something above 0?

Is it possible you have a rewriting deadlock; what service runs on port 32400?

Edit: The availability of RewriteLog depends on the Apache version; for Apache 2.4+, the LogLevel directive rules rewrite logging as well (see the LogLevel documentation), e.g. LogLevel rewrite:trace4

2
  • It's a plex server on 32400, im almost certain mod_rewrite is on, how could i check
    – rcjsdev
    Apr 1, 2014 at 13:46
  • Do you have access to the Apache configuration, e.g. /etc/apache2/? Nowadays, usually there is a subdirectory mods-enabled which contains symbolic links for each enabled module; in my case there is one called rewrite.load which refers to ../mods-available/rewrite.load. And/or try RewriteLog.
    – Tobias
    Apr 1, 2014 at 16:37
0

If your error documents are to be served by Apache rather than your backend server process (which serves port 32400), you need to protect them from being rewritten; e.g.:

RewriteCond !^/error(401|Generic).html

before your RewriteRule (you can chain 1 to n conditions which will all need to be met for the following one RewriteRule to be executed).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .