Removing "." from links

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

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: [rentittoday] Removing "." from links

By Chris - September 27, 2010

Hi rentittoday,

I'm thinking it's that last rewrite rule there that's bungling things up. I imagine you could just remove the . from [^/.]+ in your rewrite rule, but if that doesn't work for some reason, the simplest thing to do would be to get rid of dots in your _link, as Jerry suggested.

Since you don't have any necessary dots in your _link (e.g. ".php") you can use a very simple regexp to change all dots into something else:

<a href="<?php echo preg_replace('/\./', '-', $record['_link']) ?>"><strong><?php echo $record['name'] ?></strong></a>

Does that help? Please let me know if you have any questions.
All the best,
Chris

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