Forum Moderators: phranque

Message Too Old, No Replies

beginner with mod rewrite

         

iahim

11:45 am on Aug 15, 2007 (gmt 0)

10+ Year Member



I have read and read some topics for more than 5 hours. My problem is this: I have apache on winXP SP2.

DocumentRoot "C:/htdocs"
<Directory "C:/htdocs">

I have enabled mod_rewrite and i created this: [localhost...]

inside i have the .htaccess:

RewriteEngine on
Options +FollowSymlinks
RewriteRule ^nu.html$ da.html [R]

so it should redirect nu.html to da.html (http://localhost/test/da.html), but instead it redirects to:
[localhost...]

Can you please enlighten me how to solve this? the rest i can learn from web, but i haven' discovered this on www.
Thanks in advance

wilderness

2:25 pm on Aug 15, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



RewriteRule ^nu.html$ da.html [R]

Believe the above line should read:
RewriteRule ^nu.html$ [mydomain.com...] [R]

jdMorgan

2:47 pm on Aug 15, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



or to be completely-specific:

RewriteRule ^nu\.html$ http://www.mydomain.com/da.html [R=301,L]

You should place this in the .htaccess file in or above the directory where "da.html" is located, and be sure that your usage of /test and /htdocs is consistent. That is, these files should be in /htdocs/test to be consistent with the DocumentRoot setting you posted.

Jim

iahim

2:48 pm on Aug 15, 2007 (gmt 0)

10+ Year Member



Believe the above line should read:
RewriteRule ^nu.html$ [mydomain.com...] [R]

i noticed that on a linux server i can put:
RewriteRule ^nu.html$ da.html [R]
and it works perfectly. it redirects to da.html

Can i do this on XP?

i do not want to use
RewriteRule ^nu.html$ [localhost...] [R]
because this would mean to have different .htaccess for localhost and server. I want to have the same settings for mod_rewrite, is this possible?

jdMorgan

4:35 pm on Aug 15, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I don't understand the distinction you are making, but you'd do well to observe proper regular-expression-token escaping rules, to specify a 301 or 302 redirect for clarity, and to always use the [L] flag unless you have a known-good reason not to use it.

If you have multiple hosts to which you wish to apply this rule, you can always use the substitution URL construct


RewriteRule ^foo\.html$ http://[b]%{HTTP_HOST}[/b]/bar.html [R=301,L]

Using XP should have no effect, as long as its POSIX library is present and intact. There's no reason that it shouldn't be though, unless the machine has gotten corrupted.

Jim