Forum Moderators: phranque

Message Too Old, No Replies

Can't get simple rewrite rule to work

         

abapo

7:22 am on Jan 22, 2004 (gmt 0)



Alright, so I've read the tutorial, I've looked at some examples, but I still can't get this to work for some reason.

I want to make all pages from mysite.org/~someone/ appear from somethingelse.mysite.org

I've tried various RewriteRule lines, to no avail. The latest being:

Options +FollowSymlinks
RewriteEngine on

RewriteRule /(.*) [mysite.org...] [R L]

and

RewriteRule ^/(.*)$ [mysite.org...] [R]

I placed the .htaccess in the root folder for somethingelse.mysite.org . I've tried lots of other rewrite rules, but I can't remember them all. I either get a hung page which eventually times out or apache tries to show the directory listing for [somethingelse.mysite.org...] Any solutions? Thanks. :-)

jdMorgan

8:40 am on Jan 22, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



abapo,

Welcome to WebmasterWorld [webmasterworld.com]!

Drop the leading slash on RewriteRule patterns in the .htaccess context, and add a RewriteCond to prevent an infinite loop. Commas separating flags are non-optional:


RewriteCond %{REQUEST_URI} !^/~someone
RewriteRule (.*) http://mysite.org/~someone/$1 [b][R,L][/b]

Depending on what you intend to accomplish, it might be better to use a 301 redirect, or even a server-internal rewrite.
Jim