Removing "." from links

6 posts by 3 authors in: Forums > CMS Builder
Last Post: September 29, 2010   (RSS)

Hey Guys!
Some of our listings require a "." in the name of the listing.
For example:
"Cinema Camera Accesories Rental - Nikon 18mm f/3.5 Lens" is the name of our item so when we set the link with
<?php echo $record['_link'] ?>
It returns with a url that has a "." in it and browsers do not accept this.

We have tested it by manually removing the "." from the url and it displays the details page of the correct listing just fine.
Is there a way to be able to keep everything how we have it now but to strip the "."s out of the url link created?

Thanks!
Jason Glass

Re: [rentittoday] Removing "." from links

Hi rentittoday,

You might have some success using regular expressions.

You're probably using some now to insure that URLs have an http:// in the beginning of them.

Do a search for regular expressions or preg_replace on the forum or look up preg_replace on PHP.net.

Should be pretty straight forward.


Best,

Jerry Kornbluthb
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [gkornbluth] Removing "." from links

By Chris - September 27, 2010

Hi rentittoday,

I'm not sure what the problem is here. I created a record with a title of "Cinema Camera Accesories Rental - Nikon 18mm f/3.5 Lens" and it worked fine as a '_link' in my FF, IE, and Chrome.

Can you show me an example of a page where a browser won't accept your _link? Also, what browser are you using?

Can you show me the PHP source code you're currently using to output your _links?
All the best,
Chris

Re: [chris] Removing "." from links

I am using Firefox.

Here is the code for the link
<a href="<?php echo $record['_link'] ?>"><strong><?php echo $record['name'] ?></strong></a>

I did not think of it at first but we use an .htaccess file to mask the urls here, which could be the issue:
RewriteCond %{QUERY_STRING} (.*)
RewriteRule ^viewers/broadcast_equipment_rentals_details\.php$ /broadcast-video-rentals/%1? [NC,R=301]
RewriteRule ^broadcast-video-rentals/([^/.]+)/?$ /viewers/broadcast_equipment_rentals_details.php?$1 [NC,L]


When you click on the link produced from the code below and rewritten by .htaccess it gives us the url below and a completely blank page. If I remove the period from the url everything pops up just fine:
http://www.rentittoday.com/broadcast-video-rentals/Cinema-Camera-Accesories-Rental---Nikon-18mm-f-3.5-Lens-157
Jason Glass

Re: [chris] Removing "." from links

Thank for the suggestions.

I first tried your "preg_replace" and it created some crazy link urls, where it added an extra "/viewers" and the .htaccess seemed to be doing nothing. So, I then removed the preg_replace and took out the "." in the rewrite rule in .htaccess and everything works perfectly![:)]

Thanks again for your help!

Lauren
Jason Glass