title: Laravel 4 on production: 403 forbidden error on ajax call to update
body: <p>I have a laravel 4 app that works fine on just a regular save with laravel. "Regular save" meaning that I'm not using ajax to call a URL to save the data from the form but using laravel's route to the URL /revocable/users/page/1/update. </p>
  
  <p>I'm getting a 403 forbidden error during only an ajax call to a url:
  /revocable/users/page/1/update</p>
  
  <p>It's failing here:
  </p>
  
  <pre><code>$.ajax({
      type: action,
      cache: false,
      dataType: 'json',
      url: '/revocable/users/page/1/update',
      data: {
          'oSerializeArray':  [array]
      },
      beforeSend: function() {
      }
  })
      .done( function( data, text, jqxhr ) {
          data.success;
          //data.iPersonsPK;
          window.location.replace(sUrlEdit);
      })
      .fail( function ( data, jqxhr ) {
          data.success;
      })
      .always( function ( data ) {
          data.success;
      })
  
  return false;
  </code></pre>
  
  <p>I think it's my virtualhost setting of my apache httpd.conf. I didn't have a virtualhost file when I got the 403 error.</p>
  
  <p>I tried creating a virtualhost file with this:</p>
  
  <pre><code>&lt;Directory "/home/myultrat/public_html/secure/test/*"&gt;
  Options Indexes FollowSymLinks MultiViews
  AllowOverride All
  Order allow,deny 
  Allow from all
  &lt;/Directory&gt;
  
  ErrorLog /usr/local/apache/domlogs/secure.myultratrust.com.errors
  </code></pre>
  
  <p>But the problem is the same. I read that it could be a cross site script error. But it's on the same domain. All this code works well on my local machine with WAMP. So I'm thinking it's a vhost config problem.</p>
  
  <p>Oh, I have to mention that laravel app is in a sub-directory not in the "traditional" way placed in the root of a sub-domain. </p>
  
  <p>How do I resolve this problem?</p>
  
  <p>Much thanks and blessings&lt;>&lt;,
  Victor</p>
  
  <p><strong>UPDATED</strong></p>
  
  <p>Such a simple fix. I needed to update the relative URL.</p>
  
  <p>Changing the URL submitted to the $.ajax from <code>'/revocable/users/page/1/update'</code> to <code>'/test/revocable/users/page/1/update'</code> fixed the issue. @prabhakaran8737 was partially correct on the URL path not being correct. But (as I mentioned in a comment of his answer), all this time, I thought the URL was relative to where the request was made (i.e. <code>'/test/revocable/users/page/1/update'</code>) but $.ajax sees the URL call as based from it's root domain. So I needed to modify the URL to be based off the root and change it accordingly (i.e. <code>'/test/revocable/users/page/1/update'</code>).</p>
  
  <p>I tried using absolute URLs too but that didn't seem to work either. So a relative URL from the root was the answer. And the relative URL had to have the beginning <code>/</code> forward slash. I tried <code>./</code> and I tried without the forward slash too but those didn't work.</p>