Argghhh SQL Statement running 4 times instead of One... Its weird

theobserver

Pez Lightyear
Dec 7, 2013
64
1
0
Hi

So ive got this SQL insert statement on a page which executes on page load.

File name: job-view.php

If i go directly to that page e.g (job-view.php?id=199) it executes once.

However if I go to the SEO Friendly version

RewriteRule ^jobs/(.*)$ job-view.php?id=$1 [L]

so e.g /job/199

The SQL statement runs 4 times!

Its weird as fuck, any ideas?
 


Okay so put a mail() on there to send me a test email. and that gets executed 4 times from the SEO URL

Any ideas??
 
Holy cunting shit

I found the culprit

<link rel="stylesheet" type="text/css" href="css/smoothDivScroll.css" />

I changed to <link rel="stylesheet" type="text/css" href="/css/smoothDivScroll.css" />

and it stopped..

Im guessing because the css folder is on the root.

When relative to /job/ the file doesn't exist, so Apache was rewriting it back to the file


the requested URL = http://www.blabla.com/jobs/css/smoothDivScroll.css

RewriteRule ^jobs/(.*)$ job-view.php?id=$1 [L]

so it rewrites that to job-view.php?id=css/smoothDivScroll.css


Am I retarded? Is there a simple way to prevent this in future (apart from making sure there's no 404s)
 
Yeah im retarded... Ive changed the (.*) to ([0-9]+) so it only accepts numbers

Ive no idea why im still posting in here, probs due to my opening statement
 
Try these BEFORE your rewrite rule

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !\.(png|jpg|gif|css|js)$
 
Try these BEFORE your rewrite rule

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !\.(png|jpg|gif|css|js)$

+1 for last one, that will stop this madness! I've got the other 2 in place

Cheers!