I need help with redirects

There is a page with two domains:
www.exampleone.com
www.exampletwo.com

I need to redirect to the start page:
www.exampleone.com to www.exampleone.com/#!/news.html
www.exampletwo.com to www.exampletwo.com/#!/news.html

and last but not least: for each page I need to redirect, for example: www.exampleone.com/about.html to www.exampleone.com/#!/about.html www.exampletwo.com/about.html to www.exampletwo.com/#!/about.html

I really don't know how to solve this, should I use Javascript or .htaccess? for the last redirect in my example is it better to use conditions? but how?

any ideas?

Note. The content is loaded using ajax, so the index page is always the same, so the /#!/... thing.

EDIT: direct, there are live addresses http://www.jester04.ch or http://www.jester04baden.ch , the redirection of the start page is solved, as you can see in the js file, but for the redirection /#!/ I still need help, thanks.

+4
source share
3 answers

You can put this block of JS code in a separate .js file, and then include this file on each page:

 var sURL = (window.location.href + "").replace("http://", ""); if (sURL.indexOf("/#!/") < 0) { if (sURL.substr(sURL.length - 1, 1) == "/") sURL = sURL.substr(0, sURL.length - 1); var arrTemp = sURL.split("/"); var sDomain = arrTemp[0]; var sPage = (arrTemp.length > 1) ? arrTemp[arrTemp.length - 1] : "news.html"; var sNewUrl = sDomain + "/#!/"; for (var i = 1; i < arrTemp.length - 1; i++) sNewUrl += arrTemp[i] + "/"; sNewUrl += sPage; window.location.href = "http://" + sNewUrl; } 
+2
source

First, I redirect both home pages:

 RewriteCond %{REQUEST_URI} ^/$ RewriteRule (.*) /#!/news.html [R,L] 

Then all other pages

 RewriteRule (.*) /#!/$1 [R,L] 

Not tested, but this should work.

+3
source

Must work:

 redirect 301 / http://www.exampleone.com/#!/news.html redirect 301 /about.html http://www.exampleone.com/#!/about.html 

same for exampletwo.com

Put this in the .htaccess file in the root folder.

0
source

All Articles