httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Johnson <pe...@wizardslair.net>
Subject Re: [users@httpd] mod_rewrite questions?
Date Fri, 12 Nov 2004 03:35:08 GMT
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Bagus,<br>
<br>
Sorry the space in RewriteRule was a typo. And you need to enable the
rewriting capabilities by "RewriteEngine On" directive.<br>
<br>
If you don't have a bunch of AddModule / LoadModule lines in your
httpd.conf then they must be being included. Neither should have a
space. They should read something like the following<br>
<br>
AddModule mod_rewrite.c<br>
LoadModule rewrite_module /usr/lib/apache/1.3/mod_rewrite.so<br>
<br>
The space after the first $ is to break up the RewriteRule parts so
that it reads <br>
replace ^(.*)$ with /ultimate$1&nbsp; or to explain it<br>
<br>
^(.*)$ means match every character from start (^) to end ($) and store
in a variable ($1)<br>
/ultimate$1 means set uri to /ultimate and append requested path
contained in variable from match ($1)<br>
<br>
Also, is there any reason why you are server parsing html and not shtml?<br>
<br>
PJ<br>
<br>
Bagus wrote:
<blockquote cite="midNFBBJMMIKLKCDJIPOPLFMELAEIAA.bagus@cox.net"
 type="cite">
  <pre wrap="">Thanks Peter,

I'm not sure where the AddModule and LoadModule lines would go. In
httpd.conf? Apache doesn't seem to like them there:

Also, as for your syntax, there's no space between Rewrite and Rule, is
there? And why the space after the first dollar sign?

Thanks, what I tried is below. Any help is greatly appreciated.

Bagus

httpd.conf:

Load Module mod_rewrite
Add Module mod_rewrite

&lt;VirtualHost 204.251.1.186&gt;
ServerAdmin <a class="moz-txt-link-abbreviated" href="mailto:bagus@bagus.org">bagus@bagus.org</a>
DocumentRoot /www/htdocs/
ServerName <a class="moz-txt-link-abbreviated" href="http://www.neworleansultimate.org">www.neworleansultimate.org</a>
ServerAlias neworleansultimate.org www
DirectoryIndex index.html index.cgi index.gsp index.stm
ErrorLog /usr/local/apache/var/log/www.neworleansultimate-error_log
TransferLog /usr/local/apache/var/log/www.neworleansultimate-access_log
RewriteCond %{HTTP_HOST} ^www.neworleansultimate.org$
RewriteRule ^(.*)$                   /ultimate$1
AddType text/html .shtml
AddType text/html .html
AddType text/html .stm
AddHandler server-parsed .stm .html
ApJServMount /servlets /www
&lt;/VirtualHost&gt;

bagus2&gt; /usr/local/apache/sbin/apachectl configtest
Syntax error on line 231 of /usr/local/apache/conf/httpd.conf:
Invalid command 'Load', perhaps mis-spelled or defined by a module not
included in the server configuration


  </pre>
  <blockquote type="cite">
    <pre wrap="">-----Original Message-----
From: Peter Johnson [<a class="moz-txt-link-freetext" href="mailto:peter@wizardslair.net">mailto:peter@wizardslair.net</a>]
Sent: Thursday, November 11, 2004 5:38 PM
To: <a class="moz-txt-link-abbreviated" href="mailto:users@httpd.apache.org">users@httpd.apache.org</a>
Subject: Re: [users@httpd] mod_rewrite questions?


Hi Bagus,

Mod Rewrite would do the trick.

RewriteCond %{HTTP_HOST} ^www.bar.com$
Rewrite Rule ^(.*)$                   /bar$1

You need to enable the mod_rewrite module. My Apache 1.x is getting a
little rusty but you'll need to make sure that you have both an
AddModule and LoadModule line for the rewrite module.

Hope that this helps.

PJ

Bagus wrote:

    </pre>
    <blockquote type="cite">
      <pre wrap="">Hi, hopefully this will be simple.

I have two virtual hosts pointing at the same directory root.

They are for example

<a class="moz-txt-link-freetext" href="http://www.foo.com">http://www.foo.com</a>
and <a class="moz-txt-link-freetext" href="http://www.bar.com">http://www.bar.com</a>

For various resaons I want all requests to <a class="moz-txt-link-freetext" href="http://www.bar.com">http://www.bar.com</a>
to be
redirected to <a class="moz-txt-link-freetext" href="http://www.bar.com/bar/">http://www.bar.com/bar/</a>

Is this a Mod Rewrite  issue?  What's the syntax that I'd use?

Also, when I try putting various configuration bits into the virtual
host directive in my httpd.conf I get errors with apachectl configtest.

ie adding this to a virtual host

RewriteEngine on
I get:
Syntax error on line 401 of /usr/local/apache/conf/httpd.conf:
Invalid command 'RewriteEngine', perhaps mis-spelled or defined by a
module not included in the server configuration
Is there more that I have to do to get this to work?

Thanks for any help.

Bagus
      </pre>
    </blockquote>
    <pre wrap="">

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <a class="moz-txt-link-rfc1738" href="http://httpd.apache.org/userslist.html">&lt;URL:http://httpd.apache.org/userslist.html&gt;</a>
for more info.
To unsubscribe, e-mail: <a class="moz-txt-link-abbreviated" href="mailto:users-unsubscribe@httpd.apache.org">users-unsubscribe@httpd.apache.org</a>
   "   from the digest: <a class="moz-txt-link-abbreviated" href="mailto:users-digest-unsubscribe@httpd.apache.org">users-digest-unsubscribe@httpd.apache.org</a>
For additional commands, e-mail: <a class="moz-txt-link-abbreviated" href="mailto:users-help@httpd.apache.org">users-help@httpd.apache.org</a>

    </pre>
  </blockquote>
  <pre wrap=""><!---->

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <a class="moz-txt-link-rfc1738" href="http://httpd.apache.org/userslist.html">&lt;URL:http://httpd.apache.org/userslist.html&gt;</a>
for more info.
To unsubscribe, e-mail: <a class="moz-txt-link-abbreviated" href="mailto:users-unsubscribe@httpd.apache.org">users-unsubscribe@httpd.apache.org</a>
   "   from the digest: <a class="moz-txt-link-abbreviated" href="mailto:users-digest-unsubscribe@httpd.apache.org">users-digest-unsubscribe@httpd.apache.org</a>
For additional commands, e-mail: <a class="moz-txt-link-abbreviated" href="mailto:users-help@httpd.apache.org">users-help@httpd.apache.org</a>

  </pre>
</blockquote>
</body>
</html>

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message