#1
Posted 05 October 2003 - 10:43 PM
Some people may allready have noticed that I often refer to a file called
.htaccess
Let me give some basics now:
The .htaccess is a special file which can be best explained as a "config file" for Apache. Apache is the program which actually takes care of ALL webpages on a linux server. So a URL like yourdomain.com/index.html is "processed" by Apache and then sent to the browser. Since noone on a shared host server can change the actual apache settings server wide (Thank god!) you need to tell Apache if you want something special.
The place to do that is the .htaccess file!
(Short note on the side for "windows" slaves: when a file starts with "." then linux considers it as a hidden file, that's why you will never see it in a folder index)
Now we know in general, what it is for. But what can it do?
Some examples (far from a complete list):
- You can use it to protect parts of your Homepage from unauthorized access. You can allow only access to an IP or an IP range. You can also require a login with username and password.
- You can turn the "directory index" off (That is the list you see in your browser if no index.--- file exists in a folder)
- You can change settings to apache-related programs like php
- You can change which "filetypes" are processed by apache or e.g. php
- You can redirect a requested URL (e.g. if you have a subdomain "sub.domain.com" and someone types domain.com/sub he would normally stay in the subfolder. You can "force" him to sub.doamin.com with a redirect)
- You can define "Rewrite rules". This is a very powerful but difficult tool. It basically changes, blocks and/or redirects a URL when certain conditions you have defined are met.
Allright. Now let us talk about "multiple" .htaccess files in different levels of folders:
You can have a .htaccess in EVERY folder of your directory tree and there is a defined system, how they apply. Let us do an example. Let's assume you have these folders:
1) public_html
2) public_html/subdomain
3) public_html/subdomain/private
Let us also assume that /subdomain is what you think it is. It is the folder for this: subdomain.yourdomain.com.
Now you create a .htaccess in all three of these folders. In short I'll call them ht-1 ht-2 and ht-3 below.
So which one "rules"? The answer is simple:
A "higher" .htacces will allways apply to the folder it is in and to all lower folders.
(ht-1 applies to all,
ht-2 to subdomain AND subdomain/private,
ht-3 ONLY to subdomain/private)
A "lower" .htaccess will always dominate a higher one if it has a different setting.
Now if you for example "disable" the directory index in ht-1 and you "enable" it in ht-3 what happens?
- You will NOT get an directory listing for
www.yourdomain.com (= Folder public_html/)
and NOT for
subdomain.yourdomain.com (or yourdomain.com/subdomain).
That is because ht-1 applies to all of these folders.
- But you will get a directory listing for
subdomain.yourdomain.com/private
(or yourdomain.com/subdomain/private)
That is because ht-3 is in this folder that belongs to this URL. Now alltough ht-1 forbids the directory index, ht-3 allows it. Thus you get it! You also would get it for all folders BELOW /private.
Now I'll stop for now since this was ment as an genral intoduction.
My first advice if you want to use the .htacces is to allways make a backup via cpanel - filemanager.
If you use FTP, make sure to enable the "list hidden" switch (often "-la") to see the .htaccess!
To find out about details for the syntax, a google search often does wonders (e.g. ".htaccess deny access")
Any question? (sure...)
:rabbit:
#2
Posted 05 October 2003 - 11:28 PM
As you've so often proved, the .HTACCESS file is capable of all kinds of wonders. I bet if you worked hard enough at it you could get it to make you breakfast in bed each morning.
Aric
The Hasweb Helpdesk and Client Area
Now Shipping (covers v10 and earlier):
cPanel: A User's Guide
WebHost Manager Administration Guide
#5
Posted 06 October 2003 - 12:29 AM
Aric
The Hasweb Helpdesk and Client Area
Now Shipping (covers v10 and earlier):
cPanel: A User's Guide
WebHost Manager Administration Guide
#6
Posted 06 October 2003 - 12:32 AM
#8
Posted 17 October 2003 - 05:02 PM
eggthrow plus has highly increased aiming accuracy. I tried eggthrow lite once and it allmost killed the neighbors :cat:
:peace:
#9
Posted 18 October 2003 - 12:46 AM
The Hasweb Helpdesk and Client Area
Now Shipping (covers v10 and earlier):
cPanel: A User's Guide
WebHost Manager Administration Guide
#11
Posted 22 October 2003 - 05:08 PM
The Hasweb Helpdesk and Client Area
Now Shipping (covers v10 and earlier):
cPanel: A User's Guide
WebHost Manager Administration Guide
#12
Posted 23 October 2003 - 03:24 PM
Options All -Indexes
and
Options -Indexes
to ask a silly question?
#13
Posted 23 October 2003 - 03:36 PM
Options All sets the "default" of "all options" thus would "reset" everything
1) Options All -Indexes
2) Options -Indexes
3) Options All
Options -Indexes
should all three therefore have the same outcome. But I would just go with 2) since it may be that "All" could change some settings from the "hasweb" default to the "Apache factory settings" ...
#14
Posted 05 November 2003 - 08:56 AM
The Rabbit said:
eggthrow plus has highly increased aiming accuracy. I tried eggthrow lite once and it allmost killed the neighbors :cat:
:peace:
God forbid someone try to use eggdrop .. they're eggs would get all hacked up and sent via DCC
#16 Guest_raggario_*
Posted 23 November 2004 - 07:31 AM
First off I want to express my thanks for this thread, it is very informative.
I do however have a question that still lingers unanswered for me, hopefully someone here can help.
I recently learned about ".htaccess" because I was trying to figure out how to block "directory browsing" on my site. In other words, when someone types a URL to a location that does not have an index page, only a folder name, and they end up getting an "Index of/foldername" directory listing, including contents of the directory.
Well I solved that problem by adding the line "Options -Indexes" to my .htaccess file. However when I did that it created a new problem that I do not know how to fix..
I have a version of phpbb installed on my site, and with the new .htaccess option, the index page of my discussion board is no longer loading.. I am only getting the error 500 page.
What do I need to do? Is there just another simple little line that I need to add to my .htaccess file, or is this where it starts getting more complex?
I appreciate any help that might shed some light for me!
The link to my site/discussion board are in my signature.
Thank you,
R.
#17
Posted 23 November 2004 - 11:22 AM
The Hasweb Helpdesk and Client Area
Now Shipping (covers v10 and earlier):
cPanel: A User's Guide
WebHost Manager Administration Guide
#18 Guest_raggario_*
Posted 23 November 2004 - 01:08 PM
Quote
Parts were left out of this line above..
I checked my "bb" directory and noticed that I had left an unnecessary copy of .htaccess sitting in there. I deleted it then retried my site, clicked my own "discussion board" link and still got an error page..
I tried pulling up http://www.rkart.us/bb/index.php in a new window and it loaded perfectly, I knew then that there was nothing wrong with the page, or even my TOP .htaccess for that matter.
I checked the actual link itself to see if there was a problem with it and what I found was that I had written the link to go here: "http://www.rkart.us/bb" and when I changed it to "http://www.rkart.us/bb/index.php" It worked after that again!
So basically I learned here that throwing the "Options -Indexes" directive into my top .htaccess affected how all my links get read. If I do not write out a full link to the actual page in whichever directory, then I will most likely get an error page if the main directory page is named anything other than "index.htm"..
That's all just a guess anyways as to what happened.
Thanks for the suggestion of where to look first Aric.
#19
Posted 23 November 2004 - 02:22 PM
The Hasweb Helpdesk and Client Area
Now Shipping (covers v10 and earlier):
cPanel: A User's Guide
WebHost Manager Administration Guide
#20 Guest_raggario_*
Posted 23 November 2004 - 09:07 PM
I only started working with it probably three days ago, so please forgive my ignorance friends!
I was experimenting with different directives when I first started manipulating my .htaccess file. I had left a line in that was definitely causing the problem with the discussion board not loading.
Quote
How simple was that? Too dammed simple!
You were right Aric it was set up wrong. I was working on some of that stuff at approximately 4:00am so I guess my eyes just glanced right over that little sneaky line without registering!
I took the line out, went back and reprogrammed my link to simply go to "bb/" and it works perfectly :mrgreen:
It would seem that that was the answer, If there is more to it than what I've found then please let me know. I know that I've only touched the very basics of what one can do with their .htaccess file.
#21
Posted 23 November 2004 - 09:35 PM
The Hasweb Helpdesk and Client Area
Now Shipping (covers v10 and earlier):
cPanel: A User's Guide
WebHost Manager Administration Guide
#22
Posted 24 November 2004 - 06:04 PM
To late now, eh?
Glad it worked out for you !
#23
Posted 21 August 2005 - 07:54 AM
i've got a forum hosted at propertyeco.com
at the moment the forum is hosted in the subfolder /forum
so im using a simple redirect file in index.php of propertyeco.com and it redirs to propertyeco.com/forum
i'd like to know how though, how would i make the .htaccess so that visiting propertyeco.com actuallys reads the files inside /forum while keeping the url the same propertyeco.com and not propertyeco.com/forum
#24
Posted 21 August 2005 - 11:53 AM
The Hasweb Helpdesk and Client Area
Now Shipping (covers v10 and earlier):
cPanel: A User's Guide
WebHost Manager Administration Guide
#25
Posted 21 August 2005 - 07:51 PM
i just dont know any of the things to write one
and a google on tutorials either overloads me with info (eg. apache docs) or isnt what im after. most are for search engine friendly urls etc.
it's doable because i remember doing it before for one of my mambo installs so it seemed completely transperant and all files were in the root but actually were in /mambo - just cant find the guide i used now =(
will check out the gallery one when im free . its not overly urgent but yeh if someone knows plz help!
thanks
#26
Posted 25 August 2005 - 04:52 PM
#28
Posted 01 December 2006 - 09:39 PM
Here's the .htaccess that isn't working:
Options FollowSymLinks RewriteEngine On RewriteRule ^([a-z0-9_-]+)/?$ index.php?seccion=$1 [NC,L]
And this, is other .htacces that's working in a folder of my domain (not the add-on domain):
Options FollowSymLinks RewriteEngine On RewriteRule ^web/?$ index.php [NC,L] RewriteRule ^web/([a-z0-9_-]+)/?$ index.php?sec=$1 [NC,L] RewriteRule ^sistema/?$ sistema.php [NC,L] RewriteRule ^sistema/([a-z0-9_-]+)/email=(.+)/codigo=(.+)/?$ sistema.php?sec=$1&email=$2&codigo=$3 [NC,L] RewriteRule ^sistema/([a-z0-9_-]+)/?$ sistema.php?sec=$1 [NC,L]
And this is the error I'm getting on the Error Log
Invalid command '\xef\xbb\xbfOptions', perhaps mis-spelled or defined by a module not included in the server configuration
As u can see, is almost the same.. but i can't make it works.. any help? ^^
PS. Sorry for my english
This post has been edited by oso96_2000: 01 December 2006 - 09:40 PM
#29
Posted 02 December 2006 - 12:12 AM
The error suggests that when you edited the .htaccess file you saved the file in Windows or DOS format or perhaps accidentally included a non-ASCII character or other extended character.
Still, to know for certain, I'd have to see the .htaccess files. PM me with details if you want to.
Also remember that an .htaccess in public_html take precidence over .htaccess files in subdirectories.
Regards,
Aric
The Hasweb Helpdesk and Client Area
Now Shipping (covers v10 and earlier):
cPanel: A User's Guide
WebHost Manager Administration Guide
#30
Posted 02 December 2006 - 01:24 AM
Quote
And i tried something: copy the .htaccess file that works, and edit it with the new options.. and it works! still don't know what happen.. that thing about DOS format imabe.. anyway, thanks very much

Help






















