1

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?

1
  • 404 not found when i ran your snippet Commented Dec 19, 2015 at 12:51

1 Answer 1

1

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="/">
Sign up to request clarification or add additional context in comments.

1 Comment

<base href="/"> fixed the problem! Thanks :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.