Htaccess file stops making jquery work

so my htaccess file has this:

RewriteRule ^page/?([a-zA-Z_-])/?([a-zA-Z0-9_-~,])(.html)?$ page.php?category=$1&brand=$2 [L]

when I go to

my javascript stops working. I can’t even run an alert() statement. However, when I go to

everything works. why is that?

Does your script do anything with the querystring?

What does your web browser report as being the problem?

Can we see the problem in action ourself, so that we may find a solution for you.

what do you mean?

Given that you don’t seen to know what is meant by the querystring, it’s on to the third option.

Can we see the problem in action ourself, so that we may find a solution for you.

I was just doing some testing on localhost so I don’t have a live demo. the javascript looks like this however

<script type="text/javascript" src="jquery-1.4.2.min.js"></script>
<script type="text/javascript">

the php page doesn’t do much either…

it can be a blank page with just the javascript. the alert never appears when the page is loaded with the seo friendly urls

RewriteEngine on
RewriteRule ^goods/?([a-zA-Z_-])/?([!@#$%&()+"'&a-zA-Z0-9_-~,]*)(.html)?$ goods.php?category=$1&brand=$2 [L]

I think you might need to first find out if the page is being loaded (view source)

If there is no source to view, then you’ll need to investigate PHP-related reasons for the page not showing up.

the source is being loaded for sure. i put some random elements in there with php and html and it shows up normally.

Now that we know it’s loading, we can investigate why it’s not running.

What is the code that you’re shown when you view source?

I purposely left the content blank… but I’ve tried it with some text earlier and it had the same problem. the title is generated from php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>Some title</title>
<meta name="keywords" content="" />
<meta name="description" content="description here" />
<link href=style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="jquery-1.4.2.min.js"></script>
<script type="text/javascript">


<div id="container">


I also get an empty screen due to your local jQuery library not being available (of course) but when I use instead it works.

Which web browser are you using, and have you confirmed that your web browser is correctly loading the library?

Try using the above source for the jquery library instead. If it works then you know where the problem is.


it works if the url is

but if the url is:

nothing happens.

hey it worked! thanks!!!

is there a repping system on sitepoint? i wanna give u reps lol

Excellent. Your work is not over yet though.

Now go to our Apache Configuration forum and find out why your mod_rewrite is causing trouble when the web page tries to load resources from your web site, because it’s likely to affect css and images along with loading scripts from your site.

There isn’t at this stage, but the administrators are certainly considering it. :slight_smile: