Been trying to figure this one out for a day with little luck so here it is. Yahoo decided to drop the ending slashes on my directory style links in their search engine. For example, a Yahoo search shows my url as domain.com/az when it should be domain.com/az/. When you click you get a 404 error. I am using this rewrite in my htaccess file to set a url variable:
Code: Select all
RewriteEngine On
Rewritecond %{http_host} ^www.*$
RewriteRule (.*) http://domain.com/$1 їR=301,L]
RewriteCond %{REQUEST_URI} !-s
RewriteRule ^az/(.*) /template/aztemplate.php?dkey=$1
So then my template searches a mysql db for a matching URL to create a page. But without the slash, nothing is found. Here is my testing code:
Code: Select all
<?php
//db connection removed for simplicity
$dkey = (string) $_GET['dkey'];
echo $dkey;
?>
The URL domain.com/az/ returns
az/ and domain.com/az returns
az without the slashes. I also have URLs that look like domain.com/az/city/. I am pretty new to PHP but I think I need to strip the slashes and spaces, put them in an array since there will be one or two directories, and put the slashes back, but I am stumped on how to do that. Any help would be so appreciated as my brain is fried.