Vra

ok so heres the scenario:

i got a blog on the root directory of my host then i hosted some app on a subfolder named fsGallery. now, i bought a new domain for my blog and another domain for my app. ii would like to know the proper htaccess 301 redirects in order for me to redirect the old directories to their respective new domains

here's a sample dir structure:

root/
  /app
  [blog]

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

also, originally, my app used to accept url parameters like this: app/user/1234567

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

can anyone help me plox?

Was dit nuttig?

Oplossing

It seems RewriteRules 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'll probably need to play around with the groups to redirect articles properly.

Ander wenke

Possibly not programming-related, but anyway: the proper way to do this is in the virtual host configuration file (i.e. in the <VirtualHost *:80> ... </VirtualHost> section), not in an .htaccess file. The directives to use are

 RedirectMatch permanent /app/user/([0-9+]) http://newdomainforapp.com/profile/$1
 Redirect permanent /app http://newdomainforapp.com
 Redirect permanent / http://newdomainforblog.com
Gelisensieer onder: CC-BY-SA met toeskrywing
Nie verbonde aan StackOverflow
scroll top