GetSimple Support Forum
QUESTION Convert querystring with Fancy URLS - Printable Version

+- GetSimple Support Forum (http://get-simple.info/forums)
+-- Forum: GetSimple (http://get-simple.info/forums/forumdisplay.php?fid=3)
+--- Forum: Scripts & Components (http://get-simple.info/forums/forumdisplay.php?fid=11)
+--- Thread: QUESTION Convert querystring with Fancy URLS (/showthread.php?tid=9449)



Convert querystring with Fancy URLS - The_Shopkeeper - 2016-12-06

Hi All.
This is one of the url RewriteRule problems that i've struggled with for years. I just can't get my heed around it.  Confused

I have a venues listing page that pulls data from an existing MySQL DB on my server. The slug is venues.

I've also go a venue details page (slug venue) that reads the querysting so the page can query the MySQL DB to display full details of the venue.

The url is http://www.domain.com/venue?vid=Old+Punch+House

Question: Is is possible to have a the Friendly URL such as:
http://www.domain.com/Old-Punch-House
or
http://www.domain.com/venue/Old-Punch-House

Help and advice welcomed please.
Seasonal good wishes to you all.

Cheers n beers.


RE: Read querystring with Fancy URLS on - Bigin - 2016-12-06

It's not just a simple mod_rewrite problem, to do this, you'll need to change your script.
If "fancy url" is enabled and a native page "venues" really exist, no further .htaccess changes is required.
You'll need to find the position in your script who the "?vid=Old+Punch+House" param is attached to the URL, so you'll need to change that to something like "/old-punch-house", for example. To achieve this, you can use a function like this:

PHP Code:
function createslug($text)
{
  
$text preg_replace('~[^\pL\d]+~u''-'$text);
  
$text iconv('utf-8''us-ascii//TRANSLIT'$text);
  
$text preg_replace('~[^-\w]+~'''$text);
  
$text trim($text'-');
  
$text preg_replace('~-+~''-'$text);
  
$text strtolower($text);

  return 
$text;

Later you can read the parameter with:
PHP Code:
$slug get_page_slug(false); 

good luck


RE: Convert querystring with Fancy URLS - shawn_a - 2016-12-07

Doing this with GS is a problem as GS automatically uses the last path as slug

you would need a rewrite rule to catch the venue/ and convert it to
?id=venue&venue=$2 or something


RE: Convert querystring with Fancy URLS - Bigin - 2016-12-07

That's right I'd forgotten

Then you'll need something like this:

RewriteRule ^venue/([A-Za-z0-9-\+]+)/?$ index.php?id=venue&vid=$1 [NC,L,QSA]

It allow you to link to something like /venue/Old-Punch-House but not /foo/Old-Punch-House...