homepage Welcome to WebmasterWorld Guest from 23.22.173.58
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
how to mask a URL
avnik

5+ Year Member



 
Msg#: 3519704 posted 10:17 pm on Dec 3, 2007 (gmt 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?

 

gergoe

10+ Year Member



 
Msg#: 3519704 posted 11:13 pm on Dec 3, 2007 (gmt 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]

fuleo

5+ Year Member



 
Msg#: 3519704 posted 5:08 am on Mar 2, 2008 (gmt 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 ?

rocknbil

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



 
Msg#: 3519704 posted 5:25 pm on Mar 2, 2008 (gmt 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]

g1smd

WebmasterWorld Senior Member g1smd us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 3519704 posted 6:39 pm on Mar 2, 2008 (gmt 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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved