Solved

Cloaked Rewrite/Redirect

Posted on 2004-09-30
18
331 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

724 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