How do i do a redirection please?


#1

i want that when someone click on www.mywebsite.com/page1.html

he will be redirected to www.mywebsite2.com/page1.html
i mean from page1 or website1 to page1 of website2

thanks


#2

Create a file called .htaccess (note the period) that contains the following:

Redirect permanent /page1.html http://mywebsite2.com/page1.htmlPut that in the web root directory of http://mywebsite.com/ and it will automatically redirect page1.html of that site to the page1.html of the new site.


Simon’s website
Save $100 on 1-year plans with promo code [color=#CC0000]SCJESSEY100[/color] (details)


#3

thanks it works like charm :)!


#4

hi scjessey.

I guess it is faster to modify the htaccess than to use javascript. Is that correct?

Save [color=#CC0000]$97[/color] (max discount) on dreamhost plans by using promo code: [color=#CC0000]97CRAZY[/color].


#5

Should be faster as the request will never actually render anything from page1.html but be redirected by Apache.

This also means that you don’t need to keep anything other than .htaccess on disk. You don’t need a page1.html to do the javascript redirection.

Wholly


#6

Using .htaccess is much faster. Using JavaScript is a complete no-no. You should never use JavaScript for anything like that.


Simon’s website
Save $100 on 1-year plans with promo code [color=#CC0000]SCJESSEY100[/color] (details)


#7

thanks for the clarification rlparker and scjessey.

I used to use PHP Header function to redirect. I learnt something new today :stuck_out_tongue:

Save [color=#CC0000]$97[/color] (max discount) on dreamhost plans by using promo code: [color=#CC0000]97CRAZY[/color].


#8

I learn something new here every day! But you should thank wholly and scjessey - I sat this one out! :wink:

–rlparker


#9

hahaha.

sorry sorry. yep. thanks wholly and scjessey.

and I’ve seen a lot of posts from you rlparker. I also learnt a lot from you :stuck_out_tongue:

I’m still new to DH. I signed up an account last Dec. Since then, I’m always hanging around in this forum. I do remember some of the people’s names. mark, wholly, rlparker… etc. You guys are great.

Save [color=#CC0000]$97[/color] (max discount) on dreamhost plans by using promo code: [color=#CC0000]97CRAZY[/color].


#10

Just to further clarify what I meant - there is nothing wrong with using JavaScript or PHP to perform a redirection (after some conditional logic, for example), it’s just that in this instance neither one of those methods is appropriate.


Simon’s website
Save $100 on 1-year plans with promo code [color=#CC0000]SCJESSEY100[/color] (details)


#11

thanks scjessey.

I think I should learn how to use htaccess.

Save [color=#CC0000]$97[/color] (max discount) on dreamhost plans by using promo code: [color=#CC0000]97CRAZY[/color].


#12

You’ll find most of what you need here, and in some of the related articles.


Simon’s website
Save $100 on 1-year plans with promo code [color=#CC0000]SCJESSEY100[/color] (details)


#13

Using JavaScript for redirection is pretty stupid… if a user disables JavaScript, they may end up with a blank page in such a poorly-done site.

– Dan