Subdomain / Looping problem

New to mod_rewrite? This is a good place to start.

Subdomain / Looping problem

Postby iradam » Thu Oct 23, 2003 7:43 am

I'm having a problem with looping. I'd trying to take a url like:

abc.user.domain.com/123

and turn it into:

www.domain.com/cgi-bin/test/123/abc.html

Here's the rule I'm using:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^[^.]+\.user\.domain\.com$
RewriteRule ^(.*) %{HTTP_HOST}$1 [C]
RewriteRule ^([^.]+)\.user\.domain\.com/(.*)$ http://www.domain.com/cgi-bin/test/$2/$1.html [R,L]


I get a 403 Forbidden error with the hostname repeated about 10 times in the URL. Any ideas?
iradam
 

nevermind!

Postby iradam » Thu Oct 23, 2003 8:30 am

Never mind, I fixed it with a much simpler solution:

RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.user\.domain\.com [NC]
RewriteRule ^(.*)$ http://www.domain.com/cgi-bin/test/$1/%2.html [R=301,L]
iradam
 


Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 13 guests

cron