Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

REST API not working in addon domain

Tags:

php

isset

I am new to php and handling server side.

I have a domain "www.example.co.in". And another addon domain "www.example.com". I have created a new folder "www.example.com" at the root folder(public_html) of "www.example.co.in" cpanel hoisting.

public_html-> www.example.com

Now I have written an api in php fetch_data.php which looks like the below format:

<?php 
    if(isset($_POST['test'])){
        // db connection
        // retrieve data from database
    } else {
        echo("error")
    }  
?>

Now if I put this file inside www.example.com i.e. public_html-> www.example.com -> fetch_data.php

isset($_POST['test']) is returning false.

And if I put the same file inside the root folder i.e. public_html-> fetch_data.php

I am able to fetch the data.

Note: I am using the same input.

URL: http://www.example.com/fetch_data.php <- isset not working

URL: http://www.example.co.in/fetch_data.php <- isset working

I am testing the above mentioned apis using the REST Easy extension of firefox. Rest Easy by nathan-osman

The actual path of my cpanel:

home/www.example.co.in/public_html/

And the addon domain:

home/www.example.co.in/public_html/www.example.com/

like image 719
OnePunchMan Avatar asked Dec 09 '16 12:12

OnePunchMan


3 Answers

add this to you virtual host:

ServerName example.com
ServerAlias www.example.com www.example.co.in example.co.in
like image 190
LF00 Avatar answered Oct 16 '22 07:10

LF00


Godaddy provides shared hosting where most of setup is already done. Apache setup is also done by hosting partner.

You need to set different document_root for different domains. Check Godaddy Documentation.

like image 1
anwerj Avatar answered Oct 16 '22 07:10

anwerj


I think, you have chosen a single domain hosting plan and just parked an add-on domain. You should have multi domain hosting in order to host two or more domains in the same server. Since godaddy is a shared hosting service you don't have access to apache configuration files.

Instead check amazon aws micro instance which is free and you can play around a lot with it.

like image 1
Jagadesha NH Avatar answered Oct 16 '22 09:10

Jagadesha NH