Solved

How to Enable Mod_Rewrite in Apache 2.0.40 - Redhat Linux 9

Posted on 2004-09-14
5
979 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

In my time as an SEO for the last 2 years and in the questions I have assisted with on here I have always seen the need to redirect from non-www urls to their www versions. For instance redirecting http://domain.com (http://domain.com) to http…
Over the last year I have answered a couple of basic URL rewriting questions several times so I thought I might as well have a stab at: explaining the basics, providing a few useful links and consolidating some of the most common queries into a sing…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

746 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now