LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-15-2003, 10:00 AM   #1
ApacheMan252
Member
 
Registered: Feb 2003
Posts: 37

Rep: Reputation: 15
Apache RewriteEngine


How do I set up Apache (1.3) so that the trailing slash on url's is not required?

Ex. If I go to www.domain.com/folder I get a 404 error.
If I go to www.domain.com/folder/ it works.

So far I have put:

RewriteEngine on
RewriteCond %{REQUEST_URI} ^/([/A-Za-z0-9_]*)?([A-Za-z0-9_]+)$
RewriteRule ^(.*) http://%{REQUEST_URI}/ [R]

at the end of my httpd.conf file and it doesnt work... For the modules, I have:

LoadModules rewrite_modules
AddModule mod_rewrite.c

I put the Rewrite code after the modules.

Also, when I try to start Apache, I get the following error message:

RewriteBase: only valid in per-directory config files

Is this the right way or is there a different way?

Thanks!
 
Old 02-15-2003, 01:51 PM   #2
allo
Member
 
Registered: Jan 2003
Location: Toulouse, France
Distribution: slackware 8.1+
Posts: 35

Rep: Reputation: 15
Hello,

A simple way to do it :

Insert a line like

Alias /YourAliasName "/path/to/directory/"

in the commonhttpd.conf or httpd.conf - depend of the linux distribution and version of Apache you use.

No "/" after AliasName : that's the way to say to Apache to go to the path/to/directory when you type your URL without ending "/".

Don't forget to insert also :

<Directory /path/to/directory>

</Directory>

with the good options. At least Indexes - because it's needed to browse the content of your directory.

No need of Rewrite apache module to make only that.

Hope that helps.
 
Old 02-15-2003, 03:47 PM   #3
ApacheMan252
Member
 
Registered: Feb 2003
Posts: 37

Original Poster
Rep: Reputation: 15
Thanks, I use httpd.conf and I am still not exactly clear... So I put

Alias /MyAliasName "/home/folder/"

I already have the Directory in the httpd.conf file... do I put the Alias anywhere in the httpd.conf file and how do I find my alias name?

Thanks
 
Old 02-15-2003, 04:20 PM   #4
allo
Member
 
Registered: Jan 2003
Location: Toulouse, France
Distribution: slackware 8.1+
Posts: 35

Rep: Reputation: 15
Here is an alias from the default httpd.conf apache installation of my distro.


Alias /icons/ "/var/www/icons/"

<Directory "/var/www/icons">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>

From lines above, the alias is "/icons/" -with the ending "/" - and when the URL http://localhost:80/icons/ is requested by my browser the content of /var/www/icons/ directory is displayed.

In your case :

Alias /foler "/home/folder"

Don't forget to put right permissions on the directory /home/folder". The user/group used by Apache must have the rights read + execute on your directory and the files inside the must be set to read for the User/Group used by Apache

Here is an other section of my httpd.conf :

User nobody
Group nobody

So in my case Apache runs under the User/Group nobody/nobody. See yours to set the right permissions on your /home/folder directory.
 
Old 02-15-2003, 04:32 PM   #5
ApacheMan252
Member
 
Registered: Feb 2003
Posts: 37

Original Poster
Rep: Reputation: 15
I just edited it and I got a 404 error. I know that I have the right permissions, and here is what my httpd.conf file looks like:

Alias /services/ "/home/httpd/domain/services/"

<Directory "/home/httpd/domain/services/">
Options Indexes Multi Views
AllowOverride None
Oder allow, deny
Allow from all
</Directory>

Is that right?

Also, if I go to www.domain.com/services/ it works.

Last edited by ApacheMan252; 02-15-2003 at 04:34 PM.
 
Old 02-15-2003, 04:45 PM   #6
allo
Member
 
Registered: Jan 2003
Location: Toulouse, France
Distribution: slackware 8.1+
Posts: 35

Rep: Reputation: 15
Yes, it's right

And if you put

Alias /services "/home/httpd/domain/services/"
(w/o the ending "/" in the name of the Alias

www.domain.com/services should work.

instead of

Alias /services/ "/home/httpd/domain/services/" who needs
www.domain.com/services/ with the ending "/"
 
Old 02-15-2003, 05:29 PM   #7
ApacheMan252
Member
 
Registered: Feb 2003
Posts: 37

Original Poster
Rep: Reputation: 15
weird, it doesnt work. I changed it to Alias /services "/home/httpd/domain/services/" but I still get a 404 error.
 
Old 02-15-2003, 07:55 PM   #8
ApacheMan252
Member
 
Registered: Feb 2003
Posts: 37

Original Poster
Rep: Reputation: 15
I think that I am going to want to go with the rewrite module... it seems like once it is working, it will be the best. How would I set it up?

I found this on the apache site to use -

RewriteEngine on
RewriteBase /~quux/
RewriteRule ^foo$ foo/ [R]

Thanks
 
Old 02-16-2003, 10:33 AM   #9
ApacheMan252
Member
 
Registered: Feb 2003
Posts: 37

Original Poster
Rep: Reputation: 15
I have an idea, could somebody send me their httpd.conf file that has Apache 1.3.26 and that works with the trailing slash? Would that work?
 
Old 02-16-2003, 10:59 AM   #10
ApacheMan252
Member
 
Registered: Feb 2003
Posts: 37

Original Poster
Rep: Reputation: 15
Nevermind, everything is working... No need for the httpd.conf file. Thanks anyways!
 
Old 09-04-2003, 01:43 AM   #11
excel28
Member
 
Registered: Jun 2003
Location: California
Distribution: Slackware
Posts: 72

Rep: Reputation: 15
I'm trying to setup my apache webserver without the trailing slash also. I see that you got it to work with rewrite. I've tried it but I don't get it. I've placed it parts of the file i think would work, but it doesn't. Can you tell me where you placed it?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Mail from Apache being rejected - Cannot route to sender apache@localhost.localdomain jimwillsher Linux - Networking 2 01-19-2006 12:41 AM
htaccess rewriteEngine - which variable is wrong? verbatim Programming 1 06-17-2005 06:25 AM
Apache Webserver 403 Forbidden Errors (User not in apache group?) Mankind75 Mandriva 4 07-08-2004 05:30 AM
RewriteEngine andy18 Linux - General 1 03-31-2003 12:59 PM
apache benchmarks (apache v13 / apache v20) ; large differences between benchmarking markus1982 Linux - Software 0 02-08-2003 10:53 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:46 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration