The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> problem mapping URLs
benny
post Oct 3 2006, 12:50 PM
Post #1





Group: Members
Posts: 2
Joined: 3-October 06
Member No.: 316



Hello, I'm trying to create a simple mapping where for instance widget.com/cool would map to widget.com/index.cfm . I don't want to actually forward the user to the 2nd URL - i'd like their browser to still believe it is at widget.com/cool (or widget.com/cool/index.cfm).

I've been trying with a simple server-side include, but that is messing with the paths. I guess i could create a path variable and have it everywhere in my site, but I'm wondering if there is a more simple way.

Thanks

This post has been edited by benny: Oct 3 2006, 12:50 PM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Darin McGrew
post Oct 3 2006, 01:01 PM
Post #2


WDG Member
********

Group: Root Admin
Posts: 8,272
Joined: 4-August 06
From: Mountain View, CA
Member No.: 3



The same relative URLs will work in both example.com/cool and example.com/index.cfm , however example.com/cool/ and example.com/cool/index.cfm are at a different level in the URL hierarchy, so relative URLs will need to change.

Another option is to use "root relative" URLs like /images/foo.png rather than relative URLs like ../images/foo.png or ../../images/foo.png
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Oct 3 2006, 01:08 PM
Post #3


.
********

Group: WDG Moderators
Posts: 7,867
Joined: 10-August 06
Member No.: 7



QUOTE(Darin McGrew @ Oct 3 2006, 08:01 PM) *

The same relative URLs will work in both example.com/cool and example.com/index.cfm , however example.com/cool/ and example.com/cool/index.cfm are at a different level in the URL hierarchy, so relative URLs will need to change.


Didn't you mean the opposite? unsure.gif
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
benny
post Oct 3 2006, 01:34 PM
Post #4





Group: Members
Posts: 2
Joined: 3-October 06
Member No.: 316



yeah, I'm using root relative urls and just giving a different root path depending on where the script is included from. thought there might be an easier way. I've heard there's some easier way to map paths between browser and server,

This post has been edited by benny: Oct 3 2006, 01:36 PM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Oct 3 2006, 02:57 PM
Post #5


Don't like donuts. Don't do MySpace.
********

Group: WDG Moderators
Posts: 17,967
Joined: 9-August 06
Member No.: 6



I'm confused. Are you trying to create an include directive that can be used from anywhere on your site? Then use include virtual and root relative paths.

Or are you trying to make nice URLs for the users so they won't see the real URL? Then you need mod_rewrite or something else esoteric.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Sparkyg
post Oct 3 2006, 05:52 PM
Post #6


Member
***

Group: Members
Posts: 46
Joined: 29-September 06
From: Suffolk UK
Member No.: 270



Hi There

If you are running apache server then mod_rewrite should be available

just add a couple of lines to your .htaccess file


RewriteEngine On
RewriteRule /cool /index.cfm [QSA,L]


cheers

Len
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Peter1968
post Oct 9 2006, 04:15 AM
Post #7


Serious Coder
*****

Group: Members
Posts: 448
Joined: 23-September 06
Member No.: 213



Or, if mod_rewrite isn't available:

In a .htaccess in your docroot

Redirect 301 /cool http://www.widget.com/index.cfm

You can also use <Alias>, <scriptAlias> etc, but they're a little more involved.

http://httpd.apache.org/docs/1.3/urlmapping.html
Apache's URL mapping schemes.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 21st August 2018 - 10:55 PM