I am redirecting wildcard subdomain to a external domain using .htaccess

following is the .htaccess

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^(.+?)\.example\.com$ [NC]
RewriteRule ^ https://newexample.com/%1%{REQUEST_URI} [P]

I believe I have to enable mod_proxy but not able to find the correct way to do it.

in my 000-default.conf

I need to add

ProxyPass / newexample.com/

right? I tried this but getting 500 error so I think its not the correct way to add it. would appreciate any help.


  • Read the error logs of your server. If you can't figure it out with the actual error message from the log, post everything relevant from your config files. Oct 6, 2021 at 17:39


Your Answer

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

Browse other questions tagged or ask your own question.