Forum Moderators: phranque

Message Too Old, No Replies

Using Alias to map different files in the same directory

configure Apache on Linux

         

yp_error

12:44 pm on Jan 19, 2005 (gmt 0)

10+ Year Member



Hi group!
I have a problem configuring apache on red hat linux 8.1

i want to map to two diffrent files in the same directory according to Alias provided
So if the the user types the url as [zz.zz.zzz.zzz...]
i must go to file first.html ie ie [zz.zz.zzz.zzz...]

and if the user types the url as [zz.zz.zzz.zzz...]
i must go to file second.html ie [zz.zz.zzz.zzz...]

what is happening in current situation is that whatever be the URL of the above two i am directed to second.html

I assume that DirectoryIndex property is causing it but i am not sure
I havent touched httpd.conf file and all the default settings are maintained so DocumentRoot has not been changed its still /var/www/html

My query is
with above scenarion what am i supposed to do to my conf file in /etc/conf.d/ so that everything works right?

I have tried using Redirect permanent and it works fine but i dont want to pass the absolute url which is the case in Redirect
like
Redirect permanent /tt [localhost:9001...] <==i dont want to pass this URL with PORT visible
Redirect permanent /pp [localhost:9001...]


Can mapping to two different files which are in the same directory can be done using aliases?

Following is my conf file in /etc/conf.d/ direcory

Alias /tt "/home/site/"

<Directory "/home/site/">
DirectoryIndex first.html
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>

Alias /pp "/home/site/"

<Directory "/home/site/">
DirectoryIndex second.html
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>

thanks
in advance
Ramesh

yp_error

7:19 am on Jan 20, 2005 (gmt 0)

10+ Year Member



I dont know why i didnt get an answer for my question!:( May be i was unclear about the problem ....
But then i just found out a solution and that happens to be a very simple one
Only issue with this is when i am going to use front page extensions...

I couldnt fix the problem with Alias ofcourse
but as i used URL rewriting

I used this simple URL rewriting

RewriteEngine on
RewriteRule ^/pp$ /pp/second.html [R]
RewriteRule ^/tt$ /tt/first.html [R]

in my conf file
and this solved the problem

hope this helps somebody like me!

thanks

jdMorgan

3:09 pm on Jan 20, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



yp_error,

Welcome to WebmasterWorld!

I'm glad you got it figured out. It was confusing that you seemed to want to use an 'alias', which is a very different thing from a rewrite.

Note that there are two basic functions of mod_rewrite: URL redirection, and URL rewriting. The first is an external function which involves the client (e.g. browser), while the second takes place entirely within the server.

Rewrite:


RewriteEngine on
RewriteRule ^/pp$ /pp/second.html [L]
RewriteRule ^/tt$ /tt/first.html [L]

Redirect:


RewriteEngine on
RewriteRule ^/pp$ http://www.example.com/pp/second.html [R=301,L]
RewriteRule ^/tt$ http://www.example.com/tt/first.html [R=301,L]

Since the code you posted does not conform to the usual syntax of either option, I suggest you review the mod_rewrite documentation and choose the form you want to use. This will prevent unexpected results and side-effects.

Jim

yp_error

6:15 pm on Jan 20, 2005 (gmt 0)

10+ Year Member



Thanks JD for the suggestion...:)