Solved

How to Enable Mod_Rewrite in Apache 2.0.40 - Redhat Linux 9

Posted on 2004-09-14
5
1,005 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
  • 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Apache HTTP to HTTPS redirect please. 5 50
Need assistance modifying php script 3 48
phpmyadmin installation 3 62
htaccess file 3 78
Hi, in this article I'm going to teach you how to run your own site, and how to let people in (without IP). I'll talk about and explain each step... :) By the way, everything in this Tutorial is completely free and legal. This article is for …
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

770 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