Solved

Cloaked Rewrite/Redirect

Posted on 2004-09-30
18
319 Views
Last Modified: 2010-03-04
Hi

I would like any user visiting http://my.domain.com/name
to be sent to http://www.mydomain.com/view.php?username=name

I currently have a mod-rewrite rule in place
RewriteEngine On
RewriteCond %{HTTP_HOST} ^my.domain.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/view.php?username=$1 [L]

The problem is that the user sees that he was redirected to view.php. I would like the user to still see http://my.domain.com/name in the address bar. I am doing this from the server configuration not from an individual directory.

Thank you :)
0
Comment
Question by:LiquidIce911
  • 9
  • 8
18 Comments
 
LVL 1

Author Comment

by:LiquidIce911
ID: 12208088
I'll raise point value if someone can help out.
0
 
LVL 2

Expert Comment

by:lathwood
ID: 12211322
Are you sure it redirects and doesn't cloak?

I have similar thing which works, try the following:

RewriteEngine on
RewriteRule ^/([0-9a-zA-Z]*)(/?) /view.php?username=$1 [L]

That should match any name after the initial / which contains a numbner or letter (uper or lower case). It will then take that name and send the user to view.php?username=whattheytyped without redirecting.

Neil
0
 
LVL 1

Author Comment

by:LiquidIce911
ID: 12282189
that messes up the links on the site because it links everything to them .. how can I fix that ?
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 5

Expert Comment

by:mrielf
ID: 12399159
what is your file structure on web page?
0
 
LVL 1

Author Comment

by:LiquidIce911
ID: 12436852
I have the following structure:
/html/   holds the PHP files (view.php is the important one here in this case)
/html/pictures/  holds user pictures
/html/images/   holds the website graphics
0
 
LVL 5

Expert Comment

by:mrielf
ID: 12491458
Use this:

        RewriteEngine on
        rewriteRule   ^/pictures/* - [L]
        rewriteRule   ^/images/* - [L]
        RewriteRule   ^/([^/]+)/$ /view.php?username=$1 [L]
        RewriteRule   ^/([^/]+)/(.*)$ /$2 [R]
0
 
LVL 1

Author Comment

by:LiquidIce911
ID: 12560795
It doesn't work. . Notice I am sending the user from MY.domain.com/username not from www.domain.com/username
0
 
LVL 1

Author Comment

by:LiquidIce911
ID: 12561101
I noticed you have to add the full path to it .. like /var1/domain/html/view.php?username=$1 .. it got closer to working but it still did not work fully ..
0
 
LVL 5

Expert Comment

by:mrielf
ID: 12561207
Then Place this into My.domain.com section. It uses Proxy module so ensure you enable it.


        RewriteEngine on
        RewriteRule   ^/([^/]+)/$ http://www.domain.com/view.php?username=$1 [P,L]
        RewriteRule   ^/([^/]+)/(.*)$ http://www.domain.com/$2 [P,L]

0
 
LVL 5

Expert Comment

by:mrielf
ID: 12561273
In this case

http://MY.domain.com/                          not redirected...
http://MY.domain.com/anydir/                redirected to http://www.domain.com/view.php?username=anydir
http://MY.domain.com/anydir/anyfile       redirected to http://www.domain.com/anyfile


If you want some dir on http://MY.domain.com/ not to redirected, then place this

           rewriteRule   ^/dir_not_redirected1/* - [L]
           rewriteRule   ^/dir_not_redirected2/* - [L]

right after "RewriteEngine on" row.
0
 
LVL 1

Author Comment

by:LiquidIce911
ID: 12579016
that freezes up and does not work .. if I take out the last line it forwards the page okay but does not show the images correctly.. as soon as i add the last line it all crashes
0
 
LVL 5

Expert Comment

by:mrielf
ID: 12581671
It worked for me, i checked it with your directory structure...

If the first redirect is working, then second why not (it's logicaly same as first)?

Please post some of your error log.


0
 
LVL 1

Author Comment

by:LiquidIce911
ID: 12587678
the website links are not absolute.. they are all relative.. could this cause any problems?
0
 
LVL 5

Expert Comment

by:mrielf
ID: 12591018
Please post some example...
0
 
LVL 1

Author Comment

by:LiquidIce911
ID: 12638917
RewriteEngine on
        RewriteRule   ^/([^/]+)/$ http://www.domain.com/view.php?username=$1 [P,L]
        RewriteRule   ^/([^/]+)/(.*)$ http://www.domain.com/$2 [P,L]

when I do that it does not work .. I have to change the ^/([^/]+)/(.*)$ to ^(.*)$ for the first one and the second one too. Then it goes to the page but the pictures are all messed up. Adding the folder example like you have did not solve that problem. And the links all direct to http://my.peoplegrade.com/whatever.php .. I need them to link to the normal www path such as http://www.peoplegrade.com/whatever.php
0
 
LVL 5

Accepted Solution

by:
mrielf earned 100 total points
ID: 12646409
How are the pictures included in page on www.domain.com ?

href="/pictures/anypic.jpg"
or
href="pictures/anypic.jpg"

In first case to do the thing is hard, please use the second one without the first "/"

If you do this, I think my solution will work for you...
0
 
LVL 5

Expert Comment

by:mrielf
ID: 12646671
Oh, I see your problem...

But only user pictures not displayed... for exaple images/mailuser.gif and images/addfriend3.gif and all other banner background displays properly...

I will look into your page source why pictures not displayed...

If I give user pictures in browser like this: http://MY.domain.com/USER/pictures/USERxxxx.jpg then image is displayed...

Maybe there is something with javascript, but it's not sure. I'm not good at Javascript and at HTML...
0
 
LVL 1

Author Comment

by:LiquidIce911
ID: 12651442
it's okay thanks for all your help .. I'll figure this part out or do direct linking
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hi, in this article I'm going to teach you how to run your own site, and how to let people in (without IP). I'll talk about and explain each step... :) By the way, everything in this Tutorial is completely free and legal. This article is for …
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now