Htaccess redirects old site to 2 different domains

ok so the script is:

I got a blog in the root of my host, after which I placed the application in a subfolder called fsGallery. now i bought a new domain for my blog and another domain for my application. ii would like to know the correct htaccess 301 redirects so that I redirect the old directories to their respective new domains

here's a sample dir structure:

root/
  /app
  [blog]

      

tries: redir / app to newdomainforapp.com redir [blog] at newdomainforblog.com

also, initially, my app used to accept url parameters: app / user / 1234567

so I would also like: redir / app / user / {dynamic int parameter} to parameter newdomainforapp.com/profile/ {dynamic int}

Can anyone help me make a plox?

+1


source to share


2 answers


It seems the RewriteRule should work fine.

RewriteEngine on
RewriteRule ^/?app/user/([0-9]+) http://newdomainforapp.com/profile/$1 [R=301,L]
RewriteRule ^/?app(/(.*))?$ http://newdomainforapp.com/$2 [R=301,L]
RewriteRule ^/?(.*) http://newdomainforblog.com/$1 [R=301,L]

      



You may have to play with groups to properly redirect articles.

0


source


Possibly unrelated to programming, but anyway: the correct way to do this is in the virtual host config file (i.e. in the <VirtualHost *:80>

... section </VirtualHost>

), not in a file .htaccess

. Directives for use



 RedirectMatch permanent /app/user/([0-9+]) http://newdomainforapp.com/profile/$1
 Redirect permanent /app http://newdomainforapp.com
 Redirect permanent / http://newdomainforblog.com

      

+1


source







All Articles