Forum Moderators: phranque

Message Too Old, No Replies

? on 301 for examp.com/ vs examp.com vs. examp.com/index.html

What is the technical difference?

         

Purposeinc

8:06 pm on Apr 15, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In simple terms that I hope I can understand, what is the difference between

http://www.example.com

and

http://www.example.com/

and

http://www.example.com/index.html

?

Also, I how do I write my htaccess, so that it takes all of these into account, and also handles the [www....] vs. http:// into account.

My site is set up to be www.

My real goal here though is to understand what is happening.

Thanks for those brave enough to answer.

dk

kenjas

8:47 pm on Apr 15, 2006 (gmt 0)

10+ Year Member



<IfModule mod_rewrite.c>

RewriteEngine on
RewriteBase /

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

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
RewriteRule ^index\.php$ http://www.example.com/ [R=301,L]

</IfModule>

That should set you up. The first rewrite rule redirects all calls to http://example.com to http://www.example.com

The second one redirects index.php to /

[edited by: jdMorgan at 3:02 am (utc) on April 16, 2006]
[edit reason] Formatting [/edit]

Purposeinc

2:29 am on Apr 16, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thank you.

Does that also redirect the .html in addition to the .php? or do I have to make some other modification?

Thanks!

dk

jdMorgan

3:06 am on Apr 16, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can easily modify that code to redirect .html instead of .php.

I would suggest reversing the two rule-set's order though... Most-specific first, in order to avoid stacking two external redirects if iondex.html is requested.

Jim

Purposeinc

4:33 am on Apr 16, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks JD,

I am still trying to learn the basics of what an htaccess file is. I am using one successfully, and I get what a 301 redirect is, but I still don't get what language this is, what any of the syntax means. Basically a big... Duh?

Do you have any recommendations on where I can read a simple tutorial on what language is being used, and the basics of the syntax and structure of the language.

Thanks tons!
dk

jdMorgan

3:07 pm on Apr 16, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



For more information, see the documents cited in our forum charter [webmasterworld.com] and the tutorials in the Apache forum section of the WebmasterWorld library [webmasterworld.com].

Jim