Solved

How to Enable Mod_Rewrite in Apache 2.0.40 - Redhat Linux 9

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

As Wikipedia explains 'robots.txt' as -- the robot exclusion standard, also known as the Robots Exclusion Protocol or robots.txt protocol, is a convention to prevent cooperating web spiders and other web robots from accessing all or part of a websit…
It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

789 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