?
Solved

Cloaked Rewrite/Redirect

Posted on 2004-09-30
18
Medium Priority
?
335 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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Introduction As you’re probably aware the HTTP protocol offers basic / weak authentication, which in combination with the relevant configuration on your web server, provides the ability to password protect all or part of your host.  If you were not…
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…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month10 days, 2 hours left to enroll

762 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