3

I have joomla 2.5.4 website for registered users configured with LDAP. I have copied a video in the images folder and i want to give the link to the clients. Obviously if i place the url in the browser it will open the video directly but i want that if the users place the url in the browser, it should take them to the login page/it should ask for credentials.

Any suggestions will be highly appreciated.

1
  • You could try a htaccess redirect rule.
    – Lodder
    Commented Dec 8, 2014 at 8:12

2 Answers 2

4

index.php file of joomla does not get executed when you access any media. So Joomla does not get control when direct media(images etc) link is provided.

So if you are expecting that joomla will trigger something or give control before serving the content then this will not happen.

What you can do in this case is rather then providing a direct link of the media, provide some joomla url with the requested resource (it could be anything like www.yoursite.com?view=xx&task=XX&media_url=MEDIA_URL) to user.

Create a plugin which will work on onAfterRoute event, catch this url and check whether the requested resource needs login or not. If the requested resource is allowed to access then serve the content.

3

Here's a couple of options to achieve what you're trying to do:

  1. Give your clients a link to an article containing the video, rather than directly to the video. That way you can set the required access level, and if not logged in, the user will be told to log in.

  2. Use a plugin called Content Filter, that allows you to display different content in your articles based on user login. Then add something like this in your article (after configuring the plugin):

    {f90filter REGISTERED SHOW}
    Display your media here using any method you like (e.g. AllVideos plugin).
    This is not visible to guests
    {/f90filter}
    
    {f90filter REGISTERED HIDE}
    Create a link to the login page here, or display the login module directly using
    {loadposition}. This will not be visible to logged-in users.
    {/f90filter}
    
  3. Use .htaccess to restrict access to a specific file by following these steps:

    • Create a text file called .htpasswd and make sure it's not inside your public HTML directory.
    • Using a password generation tool, create a list of usernames and encrypted passwords that will have access to your file(s). Put this info into your .htpasswd file.
    • Put the following code in your .htaccess file:

      AuthUserFile /path/to/htpasswd/file/.htpasswd
      AuthName "My media file"
      AuthType Basic
      <Files "images/yourmediafile.mp4">
        require valid-user
      </Files>
      
    • Using this option Joomla will not be used to display the file or authenticate the user. A pop-up message will be displayed asking for username and password.
2
  • Hi all, thanks for your valuable answers @johanpw - I am using LDAP authentication plugin for the users, so i guess this may not work.
    – Ferhat
    Commented Dec 10, 2014 at 5:47
  • I am using a method where I will embed the videos in the joomla articles & restrict to the videos with the use of htaccess file.
    – Ferhat
    Commented Dec 10, 2014 at 5:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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