Forum Moderators: phranque

Message Too Old, No Replies

DirectoryIndex

Change DirectoryIndex to home.php

         

Jumpman

6:47 pm on Oct 11, 2014 (gmt 0)

10+ Year Member



Sorry if my english is mess up.

Normal i have 2 linux administrators in my clan to do things for me, but it look like they take a long breake be course i get no answer back when i mail them.
I think one of them is busy to make app games but thats another history.

Im very new with Linux i use Debian if that can help and for sure i am no shark yet :-)

My problem is that i need to set DirectoryIndex to home.php instede off index.php. index.php i use to maintenance my counter strike servers through a web interface that runs from root.

All this .php files in my /var/www/ i use for administrator my counter strike servers this files is root:root and password protected through some .htaccess files.

When i try to set DirectoryIndex to home.php in /var/www/.htaccess this will work but then i have to login with username and password like i do with my index.php i don't want to do that and i dont want to move or change any thing my server administrators have made for me, maybe i mess up something have to do with the servers.

In my /var/www/ i have this .htaccess file it look like this
Order Deny,Allow

Deny From All

AuthName clan35
AuthType Basic
AuthUserFile /home/clan35/.htpasswd
require valid-user
satisfy any


In /etc/apache2/site-available/default it look like this
<VirtualHost *:80>
ServerAdmin webmaster@localhost
AccessFilename .htaccess
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
Satisfy Any
</Directory>

<Directory /var/www/icons/>
AllowOverride All
Order Allow,Deny
Allow From All
Satisfy Any
</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride all
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
SetEnvIf Remote_Addr "127\.0\.0\.1" loopback
SetEnvIf Remote_Addr "::1" loopback
CustomLog ${APACHE_LOG_DIR}/access.log combined env=!loopback
</VirtualHost>


In /home/clan35/.htpasswd it look like this i dont know if somebody could use this to something so i chance the all charters with xxxx
clan35:$xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/


Hope some of you can help a newbird like me ?

lucy24

2:09 am on Oct 12, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I can't find a
DirectoryIndex home.php

directive anywhere in your quoted config file. Where is it hiding? If it's in the htaccess for the relevant directory, then that's what you should be quoting. What else is in the htaccess?

Are you saying that all files with php extension currently require a password? If so, you'll need a <Files> envelope to make an exception for this one page. It can go either in config or in htaccess.

There is nothing technically wrong with putting some stuff in a <Directory> section and other stuff in .htaccess for the same directory-- but it's bound to cause confusion. So if you're going to maintain an htaccess at all, put everything there. (Except, of course, the initial AllowOverride directive!)

<begin digression>
In all those
Order allow,deny
Allow from all

who's getting denied? Do you really want to override all server-wide lockouts for each of these directories?

This form
Options Indexes FollowSymLinks MultiViews

isn't actually wrong, but if you're using the + form everywhere else, why not be consistent? Anyway, there's not much point in setting Options on this directory if it's always going to have an htaccess file. See above about collecting everything in the htaccess.

And what are you doing with an Indexes option anyway? Is this whole directory strictly for your own use, with no public access?
</digression>

phranque

3:02 am on Oct 13, 2014 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



welcome to WebmasterWorld, Jumpman!


your configuration should be modified or overridden as required using the DirectoryIndex Directive:
http://httpd.apache.org/docs/current/mod/mod_dir.html#directoryindex


in /var/www/.htaccess surround your mod_auth* directives with the <FilesMatch> Directive:
http://httpd.apache.org/docs/current/mod/core.html#filesmatch

the regexp of your <FilesMatch> should exclude the home.php requests but match all others.

Jumpman

12:47 pm on Oct 13, 2014 (gmt 0)

10+ Year Member



lucy24

Thats right i not make anything other what you see in my .htaccess file nothing is hidden.

Ex. my root look like this
Folder1
Folder2
Folder3
index.php
ajax.fm.php
configedit.php

I have access to all the folders owner 1001 without useing user and password

If i go www.example.com/folder1 it will work owner 1001

If i go www.example.com/index.php i need to use user and password to see the site owner 0 must remain so.

But i have this home.php i want to upload to root i can do that and give it owner 1001 and i stil need user and password to see home.php needs to change so i can use this file witout user and password.

If i set DirectoryIndex home.php in my .htaccess i still need user and password but then i can not use index.php there is my entrance to maintain my counter strike servers.

I'll just read your message through a few times to catch your explanation I're no expert in either Linux or Apache to me it sounds rather complicated but i will find out.

phranque
Thanks.

It sounds very sensible, i will look at it and test it out thaks for the links

lucy24

5:12 pm on Oct 13, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



but then i can not use index.php

There can only be one index file per directory. But you're still free to make files with other names, including "index.anything". One directory on my test site has files named
index.html
index.htm
AND
index.php
just for experimental purposes. The site doesn't care; it grabs the first file it finds.

There are two ways to exclude a file from the password requirement. One way is to make a <Files> envelope
<Files home.php>
blahblah
</Files>

to exclude this page from the password requirement. The other is to make a <FilesMatch> envelope
<FilesMatch (name|othername|thirdname)\.php>
blahblah
</FilesMatch>

or, in the alternative
<FilesMatch (?<!home)\.php>
etcetera

and shift the existing password rules inside the envelope. Either way the envelope goes inside the <Directory> section for the relevant directory, so you don't accidentally set rules for other files in other directories with the same name.

Jumpman

8:38 pm on Oct 14, 2014 (gmt 0)

10+ Year Member



Ok now i get Internal Server Error

my .htaccess file now look like this
<Directory /var/www>
DirectoryIndex home.php index.php

Order Deny,Allow

Deny From All

AuthName clan35
AuthType Basic
AuthUserFile /home/clan35/.htpasswd
require valid-user
satisfy any
</Directory>

<Files "home.php">
satisfy any
order deny,allow
allow from all
</Files>


If i do like this i know it's wrong but then home.php work without user and password
Order Deny,Allow

Deny From All

AuthName clan35
AuthType Basic
AuthUserFile /home/clan35/.htpasswd
require valid-user
satisfy any

<Files "home.php">
satisfy any
order deny,allow
allow from all
</Files>

but then when i try www.example.com index.php is still the default page it start with i don't understand DirectoryIndex Directive configuration how to get home.php to be the start page ?

phranque

8:47 pm on Oct 14, 2014 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Ok now i get Internal Server Error

what does your server error log say?

If i do like this i know it's wrong but then home.php work without user and password
...
but then when i try www.example.com index.php is still the default page it start with i don't understand DirectoryIndex Directive configuration how to get home.php to be the start page ?

where is the DirectoryIndex directive in this case?

Jumpman

12:27 pm on Oct 15, 2014 (gmt 0)

10+ Year Member



The error.log says
[Wed Oct 15 14:35:35 2014] [alert] [client 192.168.0.1] /var/www/.htaccess: <Directory not allowed here


my .htaccess look like this now
DirectoryIndex home.php index.php

Order Deny,Allow

Deny From All

AuthName clan35
AuthType Basic
AuthUserFile /home/clan35/.htpasswd
require valid-user
satisfy any

<Files "home.php">
satisfy any
order deny,allow
allow from all
</Files>


if i type www.example.com/home.php it work no username or password

if i type www.example.com/index.php it work with username and password

But when i type www.example.com it still want to have username and password and i have set DirectoryIndex to home.php index.php i don't get it ?