Solved

How to Enable Mod_Rewrite in Apache 2.0.40 - Redhat Linux 9

Posted on 2004-09-14
5
1,023 Views
Last Modified: 2010-07-27
I have been having trouble with setting mod_rewrite (or any additional module for that matter) up on my Redhat Linux 9 Box which ships with Apache 2.0.40.  Apache 2 is quite a bit different then Apache 1.3 and i'm unsure of how to enable this module.  

I looked at my httpd.conf file and it contains the entry LoadModule rewrite_module modules/mod_rewrite.so among others.  Which i'm assuming loads the module but doesn't enable it.  I know in Apache 1.3 i could just do a AddModule mod_rewrite.c to enable it but in Apache 2 i'm unsure of what to do exactly.

If anyone could help me enable this and test it on my server to ensure it's working and possibley help me with writing a regular expression for my site i would be most greatful.


Thanks in Advance
Adam
0
Comment
Question by:Adam409
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 15

Expert Comment

by:samri
ID: 12058189
hi Adam,

To load mod_rewrite, just uncomment, the line that says.

LoadModule rewrite_module modules/mod_rewrite.so

For more information:
http://httpd.apache.org/docs-2.0/mod/mod_rewrite.html

<IfModule mod_rewrite.c>
   RewriteEngine  on
  ... rewrite rule here...

</IfModule>

Some practical usage: http://httpd.apache.org/docs-2.0/misc/rewriteguide.html

0
 
LVL 15

Expert Comment

by:samri
ID: 12058235
Some simpe example that I could think of :
<IfModule mod_rewrite.c>
   RewriteEngine  on
   RewriteRule    ^/stokely/(.*)$  http://www.stokely.com/$1 [L,R]
</IfModule>

This would bring Stokely consulting website to your webnamespace :

try http://localhost/stokely/index.html   Replace localhost with your servername, and voila!
0
 

Author Comment

by:Adam409
ID: 12060364
Thanks again for the quick Response

I was able to get your sample code working on my Test Server which was great!  Now i'm trying to enable it on my website which i only have .htaccess on.  The hosting company i'm using uses Apache 1.3.27.  

What i'm wondering now is how do i get the .htaccess files to work???  I know it's enabled and i called them and they said they allow .htaccess files.  

 Sorry about these newbie questions btw.
1) Do i put the individual files within each directory that i want to allow this or do i just have the .htaccess file within the root directory of my website.

2)Because it is Apache 1.3 on my website server do i still use the <IfModule mod_rewrite.c> syntax or do i just start with RewriteEngine On Then my Rules?

3)My websites root folder is actually /web so the url to my site is http://www.mysite.com which is actually /web on the server.  What i'm wondering is does this pathing have to be reflected within my Rules i create for mod_rewrite?


If clarification is needed i am more then happy to explain what i want to do in detail.  I also increased the value of the question because i'm asking more

Thanks again
0
 
LVL 15

Accepted Solution

by:
samri earned 375 total points
ID: 12067034
hi Adam,

everybody is a beginner once.  I would still consider myself in "learning" mode too.

some tutorial on htaccess from apache : http://httpd.apache.org/docs/howto/htaccess.html

Just create a file called .htaccess in the /web folder,  and paste the following code (for starters).

RewriteEngine  on
RewriteRule    ^/stokely/(.*)$  http://www.stokely.com/$1 [L,R]

since the root of your website is in /web/, the rewriting will start from http://www.mysite.com/stokely/index.html

If you were to place the .htaccess file in /web/somedir/ for example, the URL would be http://www.mysite.com/somedir/stokely/index.html

You could use the <IfModule>..</IfModule> tag, or you may ignore that.
0

Featured Post

Business Impact of IT Communications

What are the business impacts of how well businesses communicate during an IT incident? Targeting, speed, and transparency all matter. Find out more in this infographic.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction As you’re probably aware the HTTP protocol offers basic / weak authentication, which in combination with the relevant configuration on your web server, provides the ability to password protect all or part of your host.  If you were not…
If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question