Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I am running three blogs from a wordpress multisite. Currently, I am developing a separate, non wordpress application. I want to link this application with blog1. I put the application in the subfoler of my root directory (The Wordpress multisite is installed in the root). I linked the application in the menu of blog1. So far so good.

But, it is possible to access the application from all the three blogs. I want the application to be accessible only from blog1-domain/my-app/ but when I tried blog2-domain/my-app, it just opened normally. Generally, the application is accessible from all the three domains followed by /my-app.

I don't think it is proper to go this way. Then, what can I do to restrict my app to be accessible only from a my blog1-domain/my-app ? Or am I not using a good blog structure?. I am open to all kind of suggestions.

Thank you for your help.

share|improve this question
add comment

1 Answer

WordPress multisite uses wild card sub-domains. The problem is your application isn't integrated with WorPress. So anyone accessing the ~/my-app/ folder will see it's contents, and WordPress isn't going to stop them simply because it's a sub-folder in your WordPress installation. Restricting access to only blog1 you'll need to

Your application should use require('wp-blog-header.php'); in it's header. This will allow you to use WordPress functions within the application. You can then write a conditional in the header to restrict access to only blog1. This isn't tested so i'm not 100% sure if it would work. When the page blog1-domain/my-app/ loads it might recognize that as part of blog1. If someone goes to blog2-domain/my-app/ it might recognize it as blog2 and restrict access. You can test the code below or simply try echoing the blog ID in your app, and access it from different blogs to see if it's picking up each blog ID. If so you can restrict access with the code below.

<?php
global $blog_id;

if ($blog_id == 1) {
code here;
} 

elseif ($blog_id == 2) {
and here;
} 

else {
and default here;
}
?>
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.