I have a template page and want to replace my placeholder “variable” used in the path of all src=”” and href=”” on the page.
Paths look like this:
<link rel="stylesheet" type="text/css" href="css/VARIABLE/custom.css" />
<img src="http://somewhere.com/VARIABLE/img/1.jpg" />
which I want to change to:
<link rel="stylesheet" type="text/css" href="css/set-value/custom.css" />
<img src="http://somewhere.com/set-value/img/1.jpg" />
I first tried this with javascript/jquery client side, but I can’t get it to work properly.
So I’m wondering whether this is something I can do in .htaccess? I’m a total .htaccess newbie, so some pointers on where to start would also be appreciated.
Thanks for help!
You could use
But I’m pretty sure there are better ways to accomplish your goal. Why do you need this, what are you trying to do?
EDIT
You could use a special php page instead of the “variable”, e.g.:
Then in
variable.phpuse$_SERVER['PATH_INFO']to get the trailing path, i.e./css/custom.cssor/img/1.jpgrespectively. Then point to the correct file you want for each client (maybe based on the cookie value?).