How can I open my site without having to append a /"foldername" to the URL

jantom

New Member
Messages
14
Reaction score
0
Points
0
My index.html file resides in a folder called main. When I want browse to my site I must append a /main at the end of the URL. Is there a way around this? I thank you in advance for help.
jantom
 

GrandeMike

New Member
Messages
37
Reaction score
0
Points
0
You should be able to change which directory is used as the root directory in your cPanel. This is only if I remember correctly. You can with most hosts.

Or you can use a meta redirect in a html file in your root directory to forward any visitor, or yourself, on to the sub-folder. I forget the proper meta syntax in the header. You could just google meta redirect and find it pretty easily.
 
Last edited:

leafypiggy

Manager of Pens and Office Supplies
Staff member
Messages
3,819
Reaction score
163
Points
63
Put this line in your .htaccess:

DirectoryIndex /main/
 

jantom

New Member
Messages
14
Reaction score
0
Points
0
Thx leafypiggy. I added the line of code to the bottom of the .htaccesss file (which i learned is a hidden file.) Now when i try to browse to my site i receive a "500 internal server error" with an additional "404 not found error while trying to use error document to handle request" error. What do i do now. thx.
 
Last edited:

leafypiggy

Manager of Pens and Office Supplies
Staff member
Messages
3,819
Reaction score
163
Points
63
You will have to use an ftp client like FileZilla to see hidden (or dot files)

Just use your cPanel info to connect to the server. If all else fails, create the file locally on your computer, and just use cPanel to upload it.
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
I'd be very surprised if leafypiggy's approach worked. By setting DirectoryIndex in .htaccess for DOCUMENT_ROOT, anytime a user requested a URL that resolved to a directory, Apache would serve up DOCUMENT_ROOT/main/. If a user requested "/foo/bar/" zhe'd get "/main/". Moreover, Apache would no longer look for index.html when resolving a directory URI. I'm guessing this last fact is part of why you're getting to 500 error. All of the preceding doesn't apply when DirectoryIndex is set for a subfolder.

You can use an external redirect, as GrandeMike suggests, or you can use rewrites (if you don't like that guide, Google will turn up plenty of others).

I have to ask: why did you organize your site that way?
 

jantom

New Member
Messages
14
Reaction score
0
Points
0
Thx for your reply. I'm not sure what u meant by why did i organize the site this way. The folder structure is what was presented to me when I logged into cpanel. I added the CSS folder to hold my style file(s) and the image folder to hold site image(s). The folder "main" was actualy named "jantom" which is my account name. I don't know why that is. I renamed it to "main". As of now, I totally fobar'd. I did try leaftpiggy suggestion and it didn't work and to make matters worse i believe i deleted a .htaccess file. How can i wipe the slate clean and start over? The site was in it's development infancy so i'm not losing anything except time as of now.
 

garrettroyce

Community Support
Community Support
Messages
5,609
Reaction score
250
Points
63
I don't really understand what you did but, try doing a restore (cpanel->r1soft restore backups) to the earliest date. Hopefully this will put it back into a working state.
 
Last edited:

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
Thx for your reply. I'm not sure what u meant by why did i organize the site this way.
I was wondering why you had your entry page in /main/ rather than /. Site organization mostly involves what URLs access which pages (and thus where files are stored on disc), what content is on which page and how the pages link to each other; it was the first category I was referring to when I asked the question.

The folder structure is what was presented to me when I logged into cpanel. I added the CSS folder to hold my style file(s) and the image folder to hold site image(s). The folder "main" was actualy named "jantom" which is my account name. I don't know why that is. I renamed it to "main".

And all of these are under public_html? In that case, it'd probably be better to do away with /main and place index.html in DOCUMENT_ROOT. That's both a more standard and conceptually sound approach.

As of now, I totally fobar'd. I did try leaftpiggy suggestion and it didn't work and to make matters worse i believe i deleted a .htaccess file. How can i wipe the slate clean and start over? The site was in it's development infancy so i'm not losing anything except time as of now.

garrettroyce's suggestion should work for restoring your site. If not, I'll post a sample .htaccess that should work for you.
 
Last edited:

mastermike

New Member
Messages
21
Reaction score
0
Points
0
or another way would be to move main and all other folders you need out of the existing public_html folder. Then delete that folder and rename /main to public_html which would make main your root. then move any other folders back into public html. No need for redirects.
 

jantom

New Member
Messages
14
Reaction score
0
Points
0
Thank you one and all for your assistance. I took a deep breath and went back to cpanel and looked for any icon that had anything remotely to do with file management. I opend FrontPage Extentions and did a cleanup. I don't use FrontPage and because it seemed from the replys that .htaccess might be a part of the problem\cure and i had also deleted one by accident, it seemed prudent at this point to go ahead and lose them all. I opened up the Index Manager and took the default for the document root and the web root. I then took out the index.html file out of the "main" folder and placed it in public-html. I tried this before and it didn't work but it works now so i think i'm back on track. Thx again and if anyone thinks I shot myself in the foot doing what i did please give me a shout back.
 

garrettroyce

Community Support
Community Support
Messages
5,609
Reaction score
250
Points
63
I can't think of any functionality you need from the htaccess. As long as you didn't delete files other than those in the public_html, I don't think you could have done any damage.
 
Last edited:

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
Thx again and if anyone thinks I shot myself in the foot doing what i did please give me a shout back.

It sounds better now, so no real harm done.

You probably learned a few things by breaking them. As Isaac Asimov (probably) said, "the most exciting phrase to hear in science, the one that heralds the new discoveries, is not 'Eureka!' (I found it) but 'That's funny...'"
 
Top