Reputation: 168
I have these rewrite rules in my .htaccess
file:
RewriteEngine On
RewriteRule ^product_info/([0-9a-zA-Z]+)/([0-9a-zA-Z_-]+)$ /product_info.php?item_id=$1&item_name=$2 [L,NC]
RewriteRule ^product_info/ - [L,NC]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*?)/?$ $1.php [L]
Everything worked fine, until rewriting url. Css,js, images are not loading anymore, so I changed url path by adding / at very beginning:
<link href = "/Style/style.css" rel = "stylesheet" type = "text/css" />
<script src="/js/jquery-1.11.2.min.js"></script>
<script src="/js/navigation.js"></script>
<script src='/js/jquery-1.8.3.min.js'></script>
<script src='/js/jquery.elevatezoom.js'></script> <----- NOT WOKRKING
That fixed my problem. But for some reason jquery.elevatezoom.js
is still not working, but everything else is just fine.
I'm using jquery.elevatezoom.js
in this page:
/product_info.php?item_id=451&item_name=Bicycle
After rewriting url -> /product_info/451/Bicycle
Js zoom usage in product_info.php
:
<script>
$("#product_pix").elevateZoom();
</script>
Even an absolute path is not fixing the problem.
How can a fix that problem?
Upvotes: 1
Views: 485
Reputation: 41229
Your problem is that, your relative URIs have their base changed. Originally, the base is /
when the page is /product_info.php
, and the browser properly fills in relative links with the /
base. But when the browser goes to a page like /product_info/foo/bar
the base suddenly becomes /product_info/foo/bar
and it tries to append that in front of all relative URLs and thus none of them load.
You can either make your links absolute, or change the URI base in the header of your pages (inbetween the <head> </head>
tags):
<base href="/">
Upvotes: 1