Advertisement
Shark5060

.htaccess redirect

Dec 16th, 2015
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. I've got the following setup:
  2.  
  3. domain1.com is my main domain, also the document root.
  4. domain2.com is an alias domain linked to domain1.com (used for variable spelling of the main domain, also .net or .de endings)
  5.  
  6. domain5.com is another domain which is linked to domain1.com but should be handled differently.
  7.  
  8. For domain5.com I need the following redirect:
  9. http://domain5.com -> http://domain1.com/subdir/
  10. http://www.domain5.com -> http://domain1.com/subdir/
  11. http://sub.domain5.com -> http://domain1.com/subdir/
  12.  
  13. I've tried the following:
  14.  
  15. #############################################################
  16. RewriteCond %{HTTP_HOST} ^(.*\.)?domain5\.com$ [NC]
  17. RewriteRule !^subdir/ /subdir%{REQUEST_URI} [L,R,NC]
  18. #############################################################
  19.  
  20. which works for everything except the last case with the subdomain - this is due to the "alias" nature of this domain :/
  21.  
  22. Since my main domain has a SSL certificate and thus every request should be handed over to https://
  23. no matter if the initial request was already HTTPS or not.
  24.  
  25. http://domain1.com -> https://domain1.com/
  26. http://www.domain1.com -> https://domain1.com/
  27. http://foo.domain1.com -> https://foo.domain1.com/
  28.  
  29. https://domain1.com -> https://domain1.com/
  30. https://www.domain1.com -> https://domain1.com/
  31. https://foo.domain1.com -> https://foo.domain1.com/
  32.  
  33. One thing to note tho - all my subdomains are (server side) handled as symlinks pointing to the respective .sub-<name> folder,
  34. this has to be respected in the rules - if possible it would be nice to NOT display these folders (meaning, the URL should still read foo.domain1.com)
  35.  
  36. foo.domain1.com -> domain1.com/.sub-foo/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement