I am trying to encode the following relative url using PHP:
/tracks/add/5449326
I tried using rawurlencode and urlencode.
Which made it look something like this: %2Ftracks%2Fadd%2F5449326
I am going to use this url in an AJAX call.
The url I'm trying to do is:
/overlay/add-track/{param1}/{param2}
{param1} is just some id
{param2} - encoded URL
However, when I try to make a call, I get 404.
In appearance, he is trying to call:
/overlay/add-track/1
So it looks like it is trying to access the decoded string.
Any ideas how to fix this?
Php
$url = rawurlencode('/tracks/add/5449326'); echo '<a href="/overlay/add-track/1/'.$url.'">Add</a>';
JS (jQuery) var href = $ ('a'). attr ('href');
$.ajax({ url: href, type: 'POST', data: {}, dataType: "json", success: function(data) {
EDIT
RewriteEngine on RewriteCond %{REQUEST_FILENAME} \.(eps|js|ico|gif|jpg|png|css|jpeg|doc|xls|doc|pdf|txt|ppt|zip)$ RewriteRule ^(.*)$ $1 [L] RewriteCond "/path/public/%{REQUEST_URI}" !-f RewriteRule ^(.*)$ /index.php/$1 [L]
source share