1

First of all i'm a beginner on these issues, sorry for this :) Actually i am a software developer.

I have a project. Many domains connect to Rest Api domain. And all domains locate same server. I want to remove CORS control from api requests.

When i try to use api.example.com subdomain, it still controls CORS.

Last solution on my mind is Apache Alias.

So i want these:

example.com - /home/example/public_html/

api.com - /home/api/public_html/

When url is example.com, it will run /home/example/public_html/ directory. When url is example.com/api/, it will run /home/api/public_html/ directory.

How can i do?

(My English may be a little bad. Sorry :/ )

okancelik
  • 111
  • 3

1 Answers1

2

The Alias is used for exactly that purpose.

See for instance in this sample virtual host entry

<VirtualHost *:80>
    ServerName www.api.example
    ServerAlias api.example
    DocumentRoot  "/home/api/public_html/"
</VirtualHost> 
<VirtualHost *:80>
    ServerName www.example.com
    ServerAlias example.com
    DocumentRoot  "/home/example/public_html/"
    Alias "/api/"  "/home/api/public_html/"
</VirtualHost> 
HBruijn
  • 72,524
  • 21
  • 127
  • 192
  • Thanks for answer @Hbruijn . I try this example. But it was an error. My api project with php (Laravel) in My api's public_html. When i set this apache config and i try, i get **500 Internal Server Error** – okancelik Feb 11 '19 at 15:53
  • Than look at the Apache error log to find out what the exact error is. – HBruijn Feb 11 '19 at 16:02
  • [:error] [pid 31822:tid 139638169626368] [client 1.2.3.4:17700] SoftException in Application.cpp:453: Mismatch between target UID (583) and UID (560) of file "/home/api/public_html/index.php" [core:error] [pid 31822:tid 139638169626368] [client 1.2.3.4:17700] End of script output before headers: index.php **This is 2 line error log** – okancelik Feb 11 '19 at 16:16
  • I think this error because of user permissions. What do you think mate? – okancelik Feb 11 '19 at 16:31
  • When i try to set all owner and group permissions to example user, example.com/api/ working. But api.com gives 500 error. I cant fixing :/ – okancelik Feb 11 '19 at 18:11
  • can you help me please? :/ @HBruijn – okancelik Feb 12 '19 at 09:09