Reputation: 51
I am trying to redirect a request https://www.mywebsite.com/product/Apple/Green (not a real link) to https://www.mywebsite.com/product.php?prod=Apple&type=green (not a real link)
I added the following rule in web.config file but it didn't seem to work
<rule name="rwrite">
<match url="^product/([A-Za-z0-9]+)/([A-Za-z0-9-]+)/?$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url=“product.php?prod={R:1}&type={R:2}" appendQueryString="true" /></rule>
I tested this code in URL Writer and it gave me the correct output. But if I upload this config file, it loads the product.php file but is not able to load the other JS files & css files included in html section.
Upvotes: 0
Views: 193
Reputation: 9950
This is not a URL rewrite issue. My guess is that you are using the relative path to load JS files & CSS files in HTML section. Maybe something looks like this:
<head>
<script src="index.js"></script>
</head>
This would have relation to the URL in the browser's address bar. To prevent this from happening, you'd need to add /
(which would relative to the root folder of the domain) to begin of file path:
<script src="/index.js"></script>
or use full path with these static files:
<script src="http://mywebsite.com/index.js"></script>
Upvotes: 1