regex - HTAccess 'Mirror Domain', respecting SSL, respecting co.uk+.com, keeping subdomain and request_uri -


i map multiple domains onto main 1 seo , simplicity purposes.

my 3 domains are

webdevguru.co.uk t3chguy.co.uk mortie.org 

i want both of example domains redirected main domain, keeping subdomain , file , query string client accessed.

for example:

str.webdevguru.co.uk => str.webdevguru.co.uk/ webdevguru.co.uk     => www.webdevguru.co.uk/ fusion.t3chguy.co.uk => fusion.webdevguru.co.uk/ mortie.org/foo?bar   => www.webdevguru.co.uk/foo?bar https://mortie.org/  => https://www.webdevguru.co.uk/ 

basically, want traffic redirected main domain, has respect https domain cms gets transferred different url, subfolder containing cms subdirectory files has following code in .htaccess.

rewriteengine on rewritecond %{http_host} ^cms\.webdevguru\.co\.uk$ [nc] rewriterule .* https://secure24447.qnop.net/~t3chguy/tools/cms%{request_uri} [r=301,l] 

this second code works absolutely fine showing further explain example. keep having issues regex keep trying, works in 1 way not in another, people please suggest above functionality?

thanks in advance

ok, give try :

# simple rule redirect mainexample.co.uk www.mainexample.co.uk rewritecond %{https} !=on [nc] rewritecond %{http_host} ^[^\.]+\.(com|co\.uk|org)$ [nc] rewriterule ^(.*)$ http://www.mainexample.co.uk/$1 [r=301,qsa,l]  # same, https rewritecond %{https} =on [nc] rewritecond %{http_host} ^[^\.]+\.(com|co\.uk|org)$ [nc] rewriterule ^(.*)$ https://www.mainexample.co.uk/$1 [r=301,qsa,l]  # here comes funny part rewritecond %{https} !=on [nc] # no htpps rewritecond %{http_host} ^(.+)\.(.+)\.(com|co\.uk|org) [nc] # capture subdomain rewritecond %{http_host} !mainexample\.co\.uk$ [nc] # not on mainexample.co.uk rewriterule ^(.*)$ http://%1.mainexample.co.uk/$1 [r=301,qsa,l] # 301 redirection mainexample keeping subdomain , request uri  # same, https rewritecond %{https} =on [nc] rewritecond %{http_host} ^(.+)\.(.+)\.(com|co\.uk|org) [nc] rewritecond %{http_host} !mainexample\.co\.uk$ [nc] rewriterule ^(.*)$ https://%1.mainexample.co.uk/$1 [r=301,qsa,l] 

there no need duplicate rules http , https, don't know how 1 rule.


edit regarding https issue :

rewritecond %{https} =on [nc] rewritecond %{http_host} ^(cms|fusion)\.[^\.]+\.(com|co\.uk|org)$ [nc] rewriterule ^(.*)$ https://secure27.qnop.net/~t3chguy/%1/$1 [r=301,qsa,l] 

Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -