Log in

View Full Version : configure htaccess from root to Index.html



johnmcjack
09-05-2012, 02:07 PM
Hi all,

I have a very simple problem but since I just started to learn coding, I still can not find the answer.. Here is the problem:
I try to configure a htaccess to redirect from my domain www.vectsore.com (http://www.vecstore.com) to my index file www.vecstore.com/Index.html (http://www.vecstore.com/Index.html) which is the homepage of the website.
As i am hosted on Godaddy, they gave me a htacces but - i don't know why- it doesn't work :


rewriteengine on
rewritecond %{HTTP_HOST} ^www.vecstore.com$ [OR]
rewritecond %{HTTP_HOST} ^vecstore.com$
rewriterule ^vecstore\.com$ "http\:\/\/vecstore\.com\/vecstore\.com\/Index\.html" [R=301,L] #50413b751e5f6


i noticed that the problem could come from the "/" after the Index.html (http://www.vecstore.com/Index.html works, http://www.vecstore.com/Index.html/ doesn't). But i didn't find how to erase it. Could somebody help me with that ?

Thansk a lot in advance!

traq
09-05-2012, 08:35 PM
I try to configure a htaccess to redirect from my domain www.vectsore.com (http://www.vecstore.com) to my index file www.vecstore.com/Index.html (http://www.vecstore.com/Index.html) which is the homepage of the website. Apache is typically set up to do this automatically. I've -never- seen a web host that doesn't display the index page when given a URL without a file specified. You shouldn't need to do anything.

i noticed that the problem could come from the "/" after the Index.html (http://www.vecstore.com/Index.html works, http://www.vecstore.com/Index.html/ doesn't).
take a look at your code:
#this command is misspelled
# should be RewriteEngine
# the setting is misspelled also
# should be On
rewriteengine on

#this command is misspelled
# should be RewriteCond
rewritecond %{HTTP_HOST} ^www.vecstore.com$ [OR]

#this command is misspelled
# should be RewriteCond
rewritecond %{HTTP_HOST} ^vecstore.com$

#this command is misspelled
# should be RewriteRule
rewriterule ^vecstore\.com$ "http\:\/\/vecstore\.com\/vecstore\.com\/Index\.html" [R=301,L]
# This rewrite doesn't make any sense.
# If someone visits vecstore.com (NO www, NO path),
# they'll be redirected to http://vecstore.com/vecstore.com/Index.html
# Is that what you want?

# one of the two above conditions will almost always be true,
# and it's not really testing what you want to test: it's testing if the Host name matches.
# Unless you're running more than one website out of the same root directory,
# the Host name will always be some variation of your domain name.
# IIUYC, you should be looking for a missing filename.
# Maybe something like this:

RewriteEngine On

RewriteCond %{REQUEST_URI} !-f # if requested url is *not* a real file
RewriteCond %{REQUEST_URI} -d # but *is* a directory
RewriteRule ^.*$ http://vecstore.com$1/index.html [R=301,L] # redirect to index file for that directory

# this is untested, so you may need to fiddle with parts of it.
# I'll try it out for you when I get home.
# If I've misunderstood what you're trying to do, please explain.

johnmcjack
09-06-2012, 01:06 AM
Hi traq,

Thanks a lot for your very complete answer.

I didn't know about the apache redirection.. I don't know why it doesn't work for me, my host is go daddy, so not the worst one..

I tried out your code, unfortunately still no change : it still send me to http://www.vecstore.com/Index.html/ (http://www.vecstore.com/Index.html/) which doesn't work because of the "/" in the end..
If you have any other idea, please let me know, i'm totally lost!
Thanks a lot in advance!

djr33
09-06-2012, 01:23 AM
Apache is typically set up to do this automatically. I've -never- seen a web host that doesn't display the index page when given a URL without a file specified. You shouldn't need to do anything.Godaddy certainly has this set up by default.
I've used .htaccess on their servers and that works fine too, so the problem is in the code, not the host.

The first thing that jumps out at me... why are you using Index.html rather than index.html? It's supposed to be lowercase, and that's the default (and will almost certainly work). Filenames (and directories) in the URL (but not the domain name) are case-sensitive, so this is different-- use a lowercase "i" and it should all be fixed.


If you specifically want Index (uppercase), then you could create a redirect from index.html to Index.html.

traq
09-06-2012, 02:56 AM
try Daniel's suggestion.
RewriteEngine On
RewriteRule index.html Index.html
# that's assuming you want the Capital "Index.html".
possible explanation: your server is configured to use index.html, and so your .htaccess file is not actually matching our rules (one redirect has already occurred, and the URI is actually "index.html").

johnmcjack
09-06-2012, 02:53 PM
Hi Daniel and Adrian,

You were right about the "I" in "index.html". I didn't paid attention to that as Dreamweaver named the file like this but it was sure a problem.
I deleted the htaccess and the redirection works now perfectly (Godaddy does it by default as you said).
So thanks again for your help,

Anytime you need a vectorised something, just drop me a line :)

traq
09-06-2012, 03:41 PM
one thing to remember about web development is that the vast majority of webservers are run under linux.
One of the first reminders of this is that filenames are case-sensitive :)

djr33
09-06-2012, 07:41 PM
Also, as a warning about using Dreamweaver: there's nothing inherently bad about it if you keep an eye on what it does, but if you assume it's doing everything (that is, usually writing code, but also maybe naming files) correctly without double-checking for yourself, you're going to eventually have problems like this.

johnmcjack
09-07-2012, 09:06 AM
Hi Daniel and Adrian

Thanks for your nice advices, yes i admit relying a bit too much on dreamweaver but as i started learning the code, i hope it will get better and better and i won't make this kind of mistakes again..
On a totally different subject (but maybe you could also have nice ideas) i may ask you if you know some places/documentation/ forums where people are talking about e-commerce backend management tools (like OsCommerce for example) ?

Indeed, i'm looking for a simple tool to accept payments for clients and then send them automatically the corresponding product (zip file). Do you have any idea ? I tried OsCommerce but i would have to recreate all my frontend which i don't want to..

Thanks again, have a nice day!

djr33
09-07-2012, 09:08 AM
You should probably start a new thread for a new question. But in short, I don't think you'll get an answer here. Someone might know, but we don't often have questions about that sort of thing. You can post to check if anyone knows, though :)

johnmcjack
09-07-2012, 09:30 AM
Ok, thanks, I'll try just in case!