I'm trying to redirect this url:




I tried several ways but I'm getting errors. How to do that?

  • 1
    Add the code you have tried to your question. What error are you getting? If you access username.example.com/path/optname.html directly does it work OK? "add a custom file extension and url parameters" - You state "add" in the title, but it looks like you want to "remove" these in your example?
    – MrWhite
    Nov 5, 2016 at 15:14

1 Answer 1


Here's the sample rewrite commands you should be looking for:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.example.com [NC]
RewriteRule ^(.*)$ http://example.net/$1 [L,R=301,NC]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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