Redirecting my differant addresses to one. How do i do this?

I want my website so that when visitors visit… “http://www.earntopqualitygadgetsonline.co.uk/index.html” they are moved to “http://www.earntopqualitygadgetsonline.co.uk/” straight away.
Also i want when visitors visit… “http://earntopqualitygadgetsonline.co.uk/” they are moved to “http://www.earntopqualitygadgetsonline.co.uk/”.

Can someone tell me how to do this please?

My website files look like the following, (I took a screen shot of the page). There is a file index.html.

Thanks Mate!
:D:cool:

Sean,

The first is stripping the DirectoryIndex from the URI - which is NOT a smart thing to do so some hosts will not allow this redirection. That’s simply

RewriteRule ^index\\.html$ / [R=301,L]

The second one is forcing www in the {HTTP_HOST} which is already coded in my signature’s tutorial (and in this board’s stick threads) so I won’t bother to spoonfeed here.

Regards,

DK

Do i just created a text file using notepad, And in it put the following… After that upload it to the root folder of my website?

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.mt-example\.com$ [NC]
RewriteRule ^(.*)$ http://www.mt-example.com/$1 [L,R=301]

Will The above text file when in my website change the address from without the “www” to with it?
Can you tell me where to put the “http://earntopqualitygadgetsonline.co.uk/” and the “http://www.earntopqualitygadgetsonline.co.uk/

Sean,

That would work (so long as the file’s named .htaccess - notepad will add .txt and you don’t want that so be sure to change the name).

Personally, I’d use .? as the regex in the RewriteRule and replace /$1 with %{REQUEST_URI}. It does the same thing but is marginally cleaner (because you already have the (.*) atom available as %{REQUEST_URI}).

Obviously, replace the domain in your code like:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\\.earntopqualitygadgetsonline\\.co\\.uk$ [NC]
RewriteRule .? http://www.earntopqualitygadgetsonline.co.uk%{REQUEST_URI} [L,R=301]

Regards,

DK

I want http://earntopqualitygadgetsonline.co.uk/ to change to http://www.earntopqualitygadgetsonline.co.uk/

and…

I want http://www.earntopqualitygadgetsonline.co.uk/index.html to change to http://www.earntopqualitygadgetsonline.co.uk/

Could you please type the piece of code which i need and post it for me to copy and paste in a file then upload it to my website? Please! :smiley:

Sean,

First, I consider redirecting away from the DirectoryIndex to the directory so Apache can pick the DirectoryIndex file (index.html => /) absurd and a needless burden on Apache (small as it may be). I believe that some hosts will not allow this anyway.

Second, I’ve made it my consistent policy over the years in this forum NOT to aid “script kiddies.” Not that I’m calling you a script kiddie, please, but asking for someone to create code for you (as I’ve already done above) which you have not attempted yourself (at least you’ve shown no evidence) means that you’re not likely to learn about mod_rewrite. IMHO, using code which you do not understand is unwise so I do not support that.

In other words, SHOW your attempt and I’ll be more than willing to critique which, more often than not, results in the correct code AND the all important understanding that you’ve developed in the attempt.

Regards,

DK

Yes, thats what i want… I want it to change from “index.html” to “/” and also want it to change from without the “www” to with it. I have tryed it a good few times. I google it first and was reading it and tryed it, but it didnt work. It tryed to change the code a few times & it didnt work. Also when uploading it it was saying invalid file. I was then just asking on here to see how to do it and then compare it to what i done then fix what i done wrong.

Sean,

Please show US what you “tryed,” if you please.

Also, “invalid file?” What’s that about? IMHO, you need a tutorial about mod_rewrite so please let me direct you to the link in my signature.

Regards,

DK

Hey sean

I think this problem is called 301 htaccess redirection mostly faced in the SEO field, even i was facing that. So the thing is, you have to first know where is your site hosted like windows or linux then you need to upload that kind of code on the website. But you must be alert when you do this. So give this work only that person who has a good knowledge about this.

Thanks