redirection encounter one problem

Discuss practical ways rearrange URLs using mod_rewrite.

redirection encounter one problem

Postby sankaranarayanan » Thu Jul 17, 2008 11:51 pm

i have a website blog for multiple user. I had a Domain & With this domain my customer Opening their Blog.
For Example : http://www.username.example.com
each user has unique address. need to redirect to particular user directive example
For Example : http://www.username.example.com/username

i have encounter one problem
---------------- MY htaccess Code ---------------------
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.([^\.]+).sp.com$ [NC]
RewriteRule (^/([^\.]+).do$) http://%{HTTP_HOST}/%1/$1 [R,L]

i gave input is
http://www.req1.sp.com/services/home.do

my expected result is

http://www.req1.sp.com/req1/services/home.do


but it results---The page isn't redirecting properly in Mozilla
http://www.req1.sp.com/req1//req1//req1 ... es/home.do

how this thing will happen
im using apache 2.0
please help me find out solution
sankaranarayanan
 
Posts: 2
Joined: Thu Jul 17, 2008 11:28 pm
Location: chennai

Postby richardk » Fri Jul 18, 2008 3:04 pm

It also matches www.req1.example.com/req1/services/home.do. Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} ^www\.([^\.]+)\.example\.com$ [NC]
# Make sure it isn't already there.
RewriteCond %1%{REQUEST_URI} !^([^/]+)/\1(/.*)?$
RewriteRule ^(/.+\.do)$ http://%{HTTP_HOST}/%1$1 [R,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby sankaranarayanan » Mon Jul 21, 2008 11:08 pm

hello Richard,
It works fine.
Thanks for your reply.
sankaranarayanan
 
Posts: 2
Joined: Thu Jul 17, 2008 11:28 pm
Location: chennai


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 37 guests

cron