Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Cloaked Rewrite/Redirect

Posted on 2004-09-30
18
Medium Priority
?
339 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
Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

 
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 400 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 Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
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…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

610 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