Hi, I'm using the mod_rewrite function to have friendly URL's, but now i'm facing a little problem and i can't solve it. My .htaccess file: Options +Indexes Options +FollowSymlinks RewriteEngine on RewriteBase / RewriteRule ^game\-([0-9]*)\-(.*)\.html game.php?id=$1 [L] RewriteRule ^cat\-([0-9]*)\-(.*)\.html cat.php?id=$1 [L] RewriteRule ^cat\-([0-9]*)\-(.*)\-(.*)\.html cat.php?id=$1&page=$2 [L] RewriteRule index\-(.*)\.html$ index.php?page=$1 [L] Code (markup): Everything is working well exept ths one: RewriteRule ^cat\-([0-9]*)\-(.*)\-(.*)\.html cat.php?id=$1&page=$2 [L] Code (markup): The dynamic url's of my category page is like: cat.php?id=1 and i'm rewriting to cat-catid-cattitle.html, this is ok. Now, i'm using pagination script for my category pages and the dynamic url's are like: cat.php?id=1&page2,3,4... but i wanna rewrite this to cat-catid-cattitle-2.html, cat-catid-cattitle-3.html, cat-catid-cattitle-4.html and... Who can help me to fix this problem.
Change RewriteRule ^cat\-([0-9]*)\-(.*)\.html cat.php?id=$1 [L] RewriteRule ^cat\-([0-9]*)\-(.*)\-(.*)\.html cat.php?id=$1&page=$2 [L] to RewriteRule ^cat\-([0-9]*)\-(.*)\-(.*)\.html cat.php?id=$1&page=$2 [L] RewriteRule ^cat\-([0-9]*)\-(.*)\.html cat.php?id=$1 [L]
Hi Nintendo I got this error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-10, 10' at line 1
Is their a reason you have an extra (.*)? That looks like a mySQL error, not a mod_rewrite error. Try it with just the RewriteRule ^cat\-([0-9]*)\-(.*)\-(.*)\.html cat.php?id=$1&page=$2 [L] taken out. It might be the script trying to make the extra (.*), if it is doing something for that part of the URL.
Nope, its not working Nintendo The first page loads the query from DB, but when click on next page nothing is loading. This is the category page: http://www.game-console.nl/cat-3-Sport-Spelletjes.html Dynamic url's are http://www.game-console.nl/cat.php?id=3 when mod_rewrite is disabled the pagination script works like http://www.game-console.nl/cat.php?id=3&page=2
RewriteRule ^cat\-([0-9]*)\-(.*)\-(.*)\.html cat.php?id=$1&page=$3 [L] http://www.game-console.nl/cat-3-Sport-Spelletjes-6.html $2 told apache that the page number was listed second. In the links, you got the title listed second and the page number third.
Yes the title is listed as second and its generated by this code RewriteRule ^cat\-([0-9]*)\-(.*)\-(.*)\.html cat.php?id=$1&page=$3 [L] This is still not working, when i click next page the games are not changing.
Options +Indexes Options +FollowSymlinks RewriteEngine on RewriteBase / RewriteRule ^cat\-([0-9]*)\-([^.]+)\-([^.]+)\.html$ cat.php?id=$1&page=$2 [L] RewriteRule ^cat\-([0-9]*)\-([^.]+)\.html$ cat.php?id=$1 [L] RewriteRule ^game\-([0-9]*)\-([^.]+)\.html$ game.php?id=$1 [L] RewriteRule index\-([^.]+)\.html$ index.php?page=$1 [L] and then empty your browser cache.
Try Options +Indexes Options +FollowSymlinks RewriteEngine on RewriteBase / RewriteRule ^cat\-([^.]+)\-([^.]+)\-([^.]+)\.html$ cat.php?id=$1&page=$3 [L] RewriteRule ^cat\-([^.]+)\-([^.]+)\.html$ cat.php?id=$1 [L] RewriteRule ^game\-([^.]+)\-([^.]+)\.html$ game.php?id=$1 [L] RewriteRule ^index\-([^.]+)\.html$ index.php?page=$1 [L] with a deleted cache, and is their any other .htaccess code?
Nintendo, this one is working but there is a small problem. When i click on a category page from the home page like, http://www.game-console.nl/cat-18-Funny-Games.html i'm getting a mysql error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-10, 10' at line 1 Code (markup): But when i click on the category page itself for next pages it works but also with a smal problem. When i click on the 4th page i got this url http://www.game-console.nl/cat-18-Funny-Funny-Funny-Funny-Games-4.html Here's the full htaccess code, there is also anti hotlinking Options +Indexes Options +FollowSymlinks RewriteEngine on RewriteBase / RewriteRule ^cat\-([^.]+)\-([^.]+)\-([^.]+)\.html$ cat.php?id=$1&page=$3 [L] RewriteRule ^cat\-([^.]+)\-([^.]+)\.html$ cat.php?id=$1 [L] RewriteRule ^game\-([^.]+)\-([^.]+)\.html$ game.php?id=$1 [L] RewriteRule ^index\-([^.]+)\.html$ index.php?page=$1 [L] RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?game-console.nl [NC] RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?uwspelletjes.nl [NC] RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?minispel.be [NC] RewriteRule \.(swf|dcr)$ http://www.game-console.nl/500.html [NC,R,L] Code (markup):
Nintendo, Tnx for your help, did some changes on the script and its working now. Changed my htaccess file to: Options +Indexes Options +FollowSymlinks RewriteEngine on RewriteBase / RewriteRule ^cat-([0-9]*)-(.*)-(.*).html$ cat.php?id=$1&page=$3 [L] RewriteRule ^cat-([0-9]*)-(.*).html$ cat.php?id=$1 [L] RewriteRule ^game-([0-9]*)-(.*).html$ game.php?id=$1 [L] RewriteRule index-(.*)\.html$ index.php?page=$1 [L] RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?game-console.nl [NC] RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?uwspelletjes.nl [NC] RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?minispel.be [NC] RewriteRule \.(swf|dcr)$ http://www.game-console.nl/500.html [NC,R,L] Code (markup): When someone goes to /cat-3-sportgames.html it gives a mysql error, but all pages with /cat-3-sportgames-1.html, /cat-3-sportgames-2.html... are working perfect. I've changed all category links on the homepage to, /cat-3-sportgames-1.html and its working now. Thx again Nintendo.
Is http://www.game-console.nl/cat.php?id=18 and http://www.game-console.nl/cat-18-Funny-Games.html the same page? The script is my only guess for where the error comes from.
Yes, they are the same. The first one without friendly urls is working, but the second one is not working. I cant find anything on the script.
Nintendo, this is the part for pagination. echo '<div class="pages pkg"><div class="paginator">'; if ($begin > 1) { $cat_sql = "SELECT * FROM `game_cat` WHERE cat_ID = '".$_GET['id']."'"; $query = mysql_query($cat_sql) or die(mysql_error()); while ($cat_data = mysql_fetch_assoc($query)) $titel = str_replace(" ","-",$cat_data['cat']); echo'<a href="cat-'.$_GET['id'].'-'.$titel.'-1.html" title="Eerste pagina">« eerste]</a> <a href="cat-"'.$cat_data['cat_ID'].'"-"'.$titel.'"-'.$vorige.'.html" title="Vorige Pagina"><</a> '; } for ($i = $begin; $i <= $end; $i++) { if ($i == $page) { echo '<b>..'.$page.'..</b>'; } else { $cat_sql = "SELECT * FROM `game_cat` WHERE cat_ID = '".$_GET['id']."'"; $query3 = mysql_query($cat_sql) or die(mysql_error()); while ($cat_data = mysql_fetch_assoc($query3)) $titel = str_replace(" ","-",$cat_data['cat']); echo '<a href="cat-'.$_GET['id'].'-'.$titel.'-'.$i.'.html"> '.$i.' </a>'; } } if ($end < $num_pages) { $cat_sql = "SELECT * FROM `game_cat` WHERE cat_ID = '".$_GET['id']."'"; $query4 = mysql_query($cat_sql) or die(mysql_error()); while ($cat_data = mysql_fetch_assoc($query4)) echo ' <a href="cat-'.$_GET['id'].'-'.$titel.'-'.$volgende.'.html" title="Volgende Pagina">></a> <a href="cat-'.$cat_data['cat_ID'].'-'.$titel.'-'.$num_pages.'.html" title="Laatste Pagina">laatste »</a>'; } PHP:
Options +Indexes Options +FollowSymlinks RewriteEngine on RewriteBase / RewriteRule ^cat\-([0-9]*)\-(.*)\-(.*)\.html$ cat.php?id=$1&page=$3 [L] RewriteRule ^cat\-([0-9]*)\-(.*)\.html$ cat.php?id=$1 [L] RewriteRule ^game\-([0-9]*)\-(.*)\.html$ game.php?id=$1 [L] RewriteRule index\-(.*)\.html$ index.php?page=$1 [L] RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?game-console.nl [NC] RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?uwspelletjes.nl [NC] RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?minispel.be [NC] RewriteRule \.(swf|dcr)$ http://www.game-console.nl/500.html [NC,R,L] with the cache empty. It might be the - from Funny-Games driving mySQL bonkers. Changing - to _ would be one other idea.
Nintendo, you got it (-) this was the problem. I changed to (_) and its working now. http://www.game-console.nl/cat-18-Funny_Games.html Thanx alot nintendo.