Welcome to WebmasterWorld Guest from 23.20.79.227

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

how to mask a URL

     
10:17 pm on Dec 3, 2007 (gmt 0)

New User

5+ Year Member

joined:Dec 3, 2007
posts: 1
votes: 0


I want to mask my url to show from

for example

www.mysite.com/productdesc.php?item_id=2165

to

www.mysite.com

It doesnt matter to what link the site is clicked on theURL should always display www.mysite.com

I read through another post but wasnt able to apply that on my site.

I am on apache server. Any one got any suggestions?

11:13 pm on Dec 3, 2007 (gmt 0)

Preferred Member

10+ Year Member

joined:May 4, 2004
posts:525
votes: 0


That you can not do on the server software, you need to implement that in the code itself. Either use frames (I would not do that, one day frames might not be supported anymore), or make html forms (with the method attribute set to post) and make that submitted each time the visitor clicks something (i would not this either, too much trouble). Alternatively you can play around using an iframe, or an object, but you would be better of looking for an answer on an another forum like HTML and Browsers [webmasterworld.com] or Webmaster General [webmasterworld.com]
5:08 am on Mar 2, 2008 (gmt 0)

New User

5+ Year Member

joined:Mar 2, 2008
posts: 1
votes: 0


what about sites that implement user profiles ?
(e.g www.deviantart.com)

i want users that go to my links such as
[mysite.com...]
[mysite.com...]
[mysite.com...]

to be redirected to
[mysite.com...]
[mysite.com...]
[mysite.com...]

can i use .htaccess for the above scenario ?

5:25 pm on Mar 2, 2008 (gmt 0)

Senior Member

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Nov 28, 2004
posts:7999
votes: 0


This is a pretty common mistake with mod_rewrite - you are working it backwards. you can use mod_rewrite to redirect a SEO-friendly or keyword URL to a script that accepts long query string parameters, but it doesn't work the other way around. It doesn't "change" urls, just does redirections based on the rules you set. So you create links to

[mysite.com...]

and with mod_rewrite enabled, ONE solution is:

RewriteEngine On
# if the requested file is NOT a file
RewriteCond %{REQUEST_FILENAME} !-f
# and the requested file is NOT a directory
RewriteCond %{REQUEST_FILENAME} !-d
# direct to your parsing script
RewriteRule ^(.*)$ /your_script.php [L]

in your .htaccess file.

In your PHP/perl script, you look for and parse out the end of the query string (in this case "/jim") and use that value to populate the variable "name." The script then functions as it normally does, returning data for name=jim (or Jim!) This allows your friendly URL's to function along side your long query strings.

More on mod_rewrite [webmasterworld.com]

6:39 pm on Mar 2, 2008 (gmt 0)

Senior Member

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:July 3, 2002
posts:18903
votes: 0


*** you can use mod_rewrite to redirect a SEO-friendly or keyword URL to a script that accepts long query string parameters ***

No. That is a rewrite not a redirect.