[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

How to Enable Mod_Rewrite in Apache 2.0.40 - Redhat Linux 9

Posted on 2004-09-14
5
Medium Priority
?
1,046 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 1125 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

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

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…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses
Course of the Month14 days, 17 hours left to enroll

649 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