how to only allow one domain to access files and folders in another domain
There are a set of folder in
/var/www/vhosts/abc/content.abc.com.au/httpdocs/ folder
Ex:
/var/www/vhosts/abc/content.abc.com.au/httpdocs/62199911-74c61aaf688c0d374f23253218a12a9b81eaba4c
/var/www/vhosts/abc/content.abc.com.au/httpdocs/62199911-74c61aaf688c0d374f23253218a12a9b81eab12d
I can access files in above folders using this url:
https://content.abc.com.au/62199911-74c61aaf688c0d374f23253218a12a9b81eaba4c/index.html
https://content.abc.com.au/62199911-74c61aaf688c0d374f23253218a12a9b81eab12d/index.html
I want to prevent direct access for those urls.
Then,
I have another php file in this(/var/www/vhosts/xyz/anothercontent.pqr.com.au) folder named as "pdfview.php".
We can access the file using this url: https://abc.sample.com.au/pdfview.php
The "pdfview.php" file contain this iframe:
<iframe src="https://content.abc.com.au/62199911-74c61aaf688c0d374f23253218a12a9b81eab12d/index.html" allowfullscreen="" style="width:100%;height:100%;" frameborder="0"></iframe>
I want to access below urls only through the iframe in "pdfview.php" page in this (https://abc.sample.com.au) domain,
do not need to access in any other domain.
https://content.abc.com.au/62199911-74c61aaf688c0d374f23253218a12a9b81eaba4c/index.html
https://content.abc.com.au/62199911-74c61aaf688c0d374f23253218a12a9b81eab12d/index.html
I have tried to find a way to do this using htaccess file. but could not. is there a way to do that using htaccess or using php
javascript php .htaccess iframe
add a comment |
There are a set of folder in
/var/www/vhosts/abc/content.abc.com.au/httpdocs/ folder
Ex:
/var/www/vhosts/abc/content.abc.com.au/httpdocs/62199911-74c61aaf688c0d374f23253218a12a9b81eaba4c
/var/www/vhosts/abc/content.abc.com.au/httpdocs/62199911-74c61aaf688c0d374f23253218a12a9b81eab12d
I can access files in above folders using this url:
https://content.abc.com.au/62199911-74c61aaf688c0d374f23253218a12a9b81eaba4c/index.html
https://content.abc.com.au/62199911-74c61aaf688c0d374f23253218a12a9b81eab12d/index.html
I want to prevent direct access for those urls.
Then,
I have another php file in this(/var/www/vhosts/xyz/anothercontent.pqr.com.au) folder named as "pdfview.php".
We can access the file using this url: https://abc.sample.com.au/pdfview.php
The "pdfview.php" file contain this iframe:
<iframe src="https://content.abc.com.au/62199911-74c61aaf688c0d374f23253218a12a9b81eab12d/index.html" allowfullscreen="" style="width:100%;height:100%;" frameborder="0"></iframe>
I want to access below urls only through the iframe in "pdfview.php" page in this (https://abc.sample.com.au) domain,
do not need to access in any other domain.
https://content.abc.com.au/62199911-74c61aaf688c0d374f23253218a12a9b81eaba4c/index.html
https://content.abc.com.au/62199911-74c61aaf688c0d374f23253218a12a9b81eab12d/index.html
I have tried to find a way to do this using htaccess file. but could not. is there a way to do that using htaccess or using php
javascript php .htaccess iframe
Access-Control-Allow-Origin and php header
– line88
Nov 13 '18 at 7:31
@line88 there is no CORS AJAX request in play here, so Access-Control-Allow-Origin won’t do much. If anything, this is a case for an X-Frame-Options header.
– misorude
Nov 13 '18 at 8:02
@misorude The article at MDN is about headers and not just about AJAX CORS...let me quote for you..A response that tells the browser to allow code from any origin to access a resource will include the following:...
+ using phpheader
will give expected result
– line88
Nov 13 '18 at 8:05
@line88 “code” is the important word in what you quoted - this is about requests made via scripting code, so AJAX. A request caused by the mere presence of an iframe is not affected by this at all. “will give expected result” - no, it won’t.
– misorude
Nov 13 '18 at 8:08
add a comment |
There are a set of folder in
/var/www/vhosts/abc/content.abc.com.au/httpdocs/ folder
Ex:
/var/www/vhosts/abc/content.abc.com.au/httpdocs/62199911-74c61aaf688c0d374f23253218a12a9b81eaba4c
/var/www/vhosts/abc/content.abc.com.au/httpdocs/62199911-74c61aaf688c0d374f23253218a12a9b81eab12d
I can access files in above folders using this url:
https://content.abc.com.au/62199911-74c61aaf688c0d374f23253218a12a9b81eaba4c/index.html
https://content.abc.com.au/62199911-74c61aaf688c0d374f23253218a12a9b81eab12d/index.html
I want to prevent direct access for those urls.
Then,
I have another php file in this(/var/www/vhosts/xyz/anothercontent.pqr.com.au) folder named as "pdfview.php".
We can access the file using this url: https://abc.sample.com.au/pdfview.php
The "pdfview.php" file contain this iframe:
<iframe src="https://content.abc.com.au/62199911-74c61aaf688c0d374f23253218a12a9b81eab12d/index.html" allowfullscreen="" style="width:100%;height:100%;" frameborder="0"></iframe>
I want to access below urls only through the iframe in "pdfview.php" page in this (https://abc.sample.com.au) domain,
do not need to access in any other domain.
https://content.abc.com.au/62199911-74c61aaf688c0d374f23253218a12a9b81eaba4c/index.html
https://content.abc.com.au/62199911-74c61aaf688c0d374f23253218a12a9b81eab12d/index.html
I have tried to find a way to do this using htaccess file. but could not. is there a way to do that using htaccess or using php
javascript php .htaccess iframe
There are a set of folder in
/var/www/vhosts/abc/content.abc.com.au/httpdocs/ folder
Ex:
/var/www/vhosts/abc/content.abc.com.au/httpdocs/62199911-74c61aaf688c0d374f23253218a12a9b81eaba4c
/var/www/vhosts/abc/content.abc.com.au/httpdocs/62199911-74c61aaf688c0d374f23253218a12a9b81eab12d
I can access files in above folders using this url:
https://content.abc.com.au/62199911-74c61aaf688c0d374f23253218a12a9b81eaba4c/index.html
https://content.abc.com.au/62199911-74c61aaf688c0d374f23253218a12a9b81eab12d/index.html
I want to prevent direct access for those urls.
Then,
I have another php file in this(/var/www/vhosts/xyz/anothercontent.pqr.com.au) folder named as "pdfview.php".
We can access the file using this url: https://abc.sample.com.au/pdfview.php
The "pdfview.php" file contain this iframe:
<iframe src="https://content.abc.com.au/62199911-74c61aaf688c0d374f23253218a12a9b81eab12d/index.html" allowfullscreen="" style="width:100%;height:100%;" frameborder="0"></iframe>
I want to access below urls only through the iframe in "pdfview.php" page in this (https://abc.sample.com.au) domain,
do not need to access in any other domain.
https://content.abc.com.au/62199911-74c61aaf688c0d374f23253218a12a9b81eaba4c/index.html
https://content.abc.com.au/62199911-74c61aaf688c0d374f23253218a12a9b81eab12d/index.html
I have tried to find a way to do this using htaccess file. but could not. is there a way to do that using htaccess or using php
javascript php .htaccess iframe
javascript php .htaccess iframe
asked Nov 13 '18 at 7:27
SujaniWickramasingheSujaniWickramasinghe
196
196
Access-Control-Allow-Origin and php header
– line88
Nov 13 '18 at 7:31
@line88 there is no CORS AJAX request in play here, so Access-Control-Allow-Origin won’t do much. If anything, this is a case for an X-Frame-Options header.
– misorude
Nov 13 '18 at 8:02
@misorude The article at MDN is about headers and not just about AJAX CORS...let me quote for you..A response that tells the browser to allow code from any origin to access a resource will include the following:...
+ using phpheader
will give expected result
– line88
Nov 13 '18 at 8:05
@line88 “code” is the important word in what you quoted - this is about requests made via scripting code, so AJAX. A request caused by the mere presence of an iframe is not affected by this at all. “will give expected result” - no, it won’t.
– misorude
Nov 13 '18 at 8:08
add a comment |
Access-Control-Allow-Origin and php header
– line88
Nov 13 '18 at 7:31
@line88 there is no CORS AJAX request in play here, so Access-Control-Allow-Origin won’t do much. If anything, this is a case for an X-Frame-Options header.
– misorude
Nov 13 '18 at 8:02
@misorude The article at MDN is about headers and not just about AJAX CORS...let me quote for you..A response that tells the browser to allow code from any origin to access a resource will include the following:...
+ using phpheader
will give expected result
– line88
Nov 13 '18 at 8:05
@line88 “code” is the important word in what you quoted - this is about requests made via scripting code, so AJAX. A request caused by the mere presence of an iframe is not affected by this at all. “will give expected result” - no, it won’t.
– misorude
Nov 13 '18 at 8:08
Access-Control-Allow-Origin and php header
– line88
Nov 13 '18 at 7:31
Access-Control-Allow-Origin and php header
– line88
Nov 13 '18 at 7:31
@line88 there is no CORS AJAX request in play here, so Access-Control-Allow-Origin won’t do much. If anything, this is a case for an X-Frame-Options header.
– misorude
Nov 13 '18 at 8:02
@line88 there is no CORS AJAX request in play here, so Access-Control-Allow-Origin won’t do much. If anything, this is a case for an X-Frame-Options header.
– misorude
Nov 13 '18 at 8:02
@misorude The article at MDN is about headers and not just about AJAX CORS...let me quote for you
..A response that tells the browser to allow code from any origin to access a resource will include the following:...
+ using php header
will give expected result– line88
Nov 13 '18 at 8:05
@misorude The article at MDN is about headers and not just about AJAX CORS...let me quote for you
..A response that tells the browser to allow code from any origin to access a resource will include the following:...
+ using php header
will give expected result– line88
Nov 13 '18 at 8:05
@line88 “code” is the important word in what you quoted - this is about requests made via scripting code, so AJAX. A request caused by the mere presence of an iframe is not affected by this at all. “will give expected result” - no, it won’t.
– misorude
Nov 13 '18 at 8:08
@line88 “code” is the important word in what you quoted - this is about requests made via scripting code, so AJAX. A request caused by the mere presence of an iframe is not affected by this at all. “will give expected result” - no, it won’t.
– misorude
Nov 13 '18 at 8:08
add a comment |
1 Answer
1
active
oldest
votes
How about modifying the .htaccess file.
Order Deny,Allow
Deny from all
Allow from 100.100.100.100
can you explain about the IP address 100.100.100.100 ?
– SujaniWickramasinghe
Nov 13 '18 at 7:51
When you have virtualhost <VirtualHost *:80> DocumentRoot "/opt/lampp/htdocs/yourproject" ServerName yourproject.localhost <Directory "/opt/lampp/htdocs/yourproject"> Order Deny,Allow Deny from all Allow from 100.100.100.100 (ip address of domain ) ( This one can only access the folder of project) </Directory> </VirtualHost>
– j3thamz
Nov 13 '18 at 8:05
But it is not “the domain” making the request, it is my browser.
– misorude
Nov 13 '18 at 8:10
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53275886%2fhow-to-only-allow-one-domain-to-access-files-and-folders-in-another-domain%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
How about modifying the .htaccess file.
Order Deny,Allow
Deny from all
Allow from 100.100.100.100
can you explain about the IP address 100.100.100.100 ?
– SujaniWickramasinghe
Nov 13 '18 at 7:51
When you have virtualhost <VirtualHost *:80> DocumentRoot "/opt/lampp/htdocs/yourproject" ServerName yourproject.localhost <Directory "/opt/lampp/htdocs/yourproject"> Order Deny,Allow Deny from all Allow from 100.100.100.100 (ip address of domain ) ( This one can only access the folder of project) </Directory> </VirtualHost>
– j3thamz
Nov 13 '18 at 8:05
But it is not “the domain” making the request, it is my browser.
– misorude
Nov 13 '18 at 8:10
add a comment |
How about modifying the .htaccess file.
Order Deny,Allow
Deny from all
Allow from 100.100.100.100
can you explain about the IP address 100.100.100.100 ?
– SujaniWickramasinghe
Nov 13 '18 at 7:51
When you have virtualhost <VirtualHost *:80> DocumentRoot "/opt/lampp/htdocs/yourproject" ServerName yourproject.localhost <Directory "/opt/lampp/htdocs/yourproject"> Order Deny,Allow Deny from all Allow from 100.100.100.100 (ip address of domain ) ( This one can only access the folder of project) </Directory> </VirtualHost>
– j3thamz
Nov 13 '18 at 8:05
But it is not “the domain” making the request, it is my browser.
– misorude
Nov 13 '18 at 8:10
add a comment |
How about modifying the .htaccess file.
Order Deny,Allow
Deny from all
Allow from 100.100.100.100
How about modifying the .htaccess file.
Order Deny,Allow
Deny from all
Allow from 100.100.100.100
answered Nov 13 '18 at 7:38
j3thamzj3thamz
764
764
can you explain about the IP address 100.100.100.100 ?
– SujaniWickramasinghe
Nov 13 '18 at 7:51
When you have virtualhost <VirtualHost *:80> DocumentRoot "/opt/lampp/htdocs/yourproject" ServerName yourproject.localhost <Directory "/opt/lampp/htdocs/yourproject"> Order Deny,Allow Deny from all Allow from 100.100.100.100 (ip address of domain ) ( This one can only access the folder of project) </Directory> </VirtualHost>
– j3thamz
Nov 13 '18 at 8:05
But it is not “the domain” making the request, it is my browser.
– misorude
Nov 13 '18 at 8:10
add a comment |
can you explain about the IP address 100.100.100.100 ?
– SujaniWickramasinghe
Nov 13 '18 at 7:51
When you have virtualhost <VirtualHost *:80> DocumentRoot "/opt/lampp/htdocs/yourproject" ServerName yourproject.localhost <Directory "/opt/lampp/htdocs/yourproject"> Order Deny,Allow Deny from all Allow from 100.100.100.100 (ip address of domain ) ( This one can only access the folder of project) </Directory> </VirtualHost>
– j3thamz
Nov 13 '18 at 8:05
But it is not “the domain” making the request, it is my browser.
– misorude
Nov 13 '18 at 8:10
can you explain about the IP address 100.100.100.100 ?
– SujaniWickramasinghe
Nov 13 '18 at 7:51
can you explain about the IP address 100.100.100.100 ?
– SujaniWickramasinghe
Nov 13 '18 at 7:51
When you have virtualhost <VirtualHost *:80> DocumentRoot "/opt/lampp/htdocs/yourproject" ServerName yourproject.localhost <Directory "/opt/lampp/htdocs/yourproject"> Order Deny,Allow Deny from all Allow from 100.100.100.100 (ip address of domain ) ( This one can only access the folder of project) </Directory> </VirtualHost>
– j3thamz
Nov 13 '18 at 8:05
When you have virtualhost <VirtualHost *:80> DocumentRoot "/opt/lampp/htdocs/yourproject" ServerName yourproject.localhost <Directory "/opt/lampp/htdocs/yourproject"> Order Deny,Allow Deny from all Allow from 100.100.100.100 (ip address of domain ) ( This one can only access the folder of project) </Directory> </VirtualHost>
– j3thamz
Nov 13 '18 at 8:05
But it is not “the domain” making the request, it is my browser.
– misorude
Nov 13 '18 at 8:10
But it is not “the domain” making the request, it is my browser.
– misorude
Nov 13 '18 at 8:10
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53275886%2fhow-to-only-allow-one-domain-to-access-files-and-folders-in-another-domain%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Access-Control-Allow-Origin and php header
– line88
Nov 13 '18 at 7:31
@line88 there is no CORS AJAX request in play here, so Access-Control-Allow-Origin won’t do much. If anything, this is a case for an X-Frame-Options header.
– misorude
Nov 13 '18 at 8:02
@misorude The article at MDN is about headers and not just about AJAX CORS...let me quote for you
..A response that tells the browser to allow code from any origin to access a resource will include the following:...
+ using phpheader
will give expected result– line88
Nov 13 '18 at 8:05
@line88 “code” is the important word in what you quoted - this is about requests made via scripting code, so AJAX. A request caused by the mere presence of an iframe is not affected by this at all. “will give expected result” - no, it won’t.
– misorude
Nov 13 '18 at 8:08