I'm running an apache web server on Ubuntu 20.04.

I have a domain.com which directs clients to the index.html. On the website there is a button that, when clicked, opens a calendal pop-up widget. I would like people who go to domain.com/schedule to land on the index page as if they had clicked that button.

How can I do that simply?

2 Answers 2


You definitely need to trigger the pop-up on the client side. Here's a quick sample you can easily try and adjust (and secure) to your needs:

      <script type="text/javascript">
        function isScheduleRequested() {
        if(window.location.href.includes('/schedule')) {
  <body onload='isScheduleRequested();'>
      <button type="button" name="button" id="button" onclick="alert('Opening calendar');">Open calendar</button>

What this does is, generally speaking, check if the URL of the current page contains the '/schedule' substring' (anywhere, not necessarily at the end, not even only once), and, if it does, then call the button's click event.

The onload='isScheduleRequested(); bit is just to make sure that the javascript script is executed after the body is loaded (and the button element exists).

You can even try this on your computer. Save this code as "index.html" and open it with your browser. Nothing will happen until you click the button. However if you append ?q=/schedule to the URI, the button's "click" event will be triggered. (In this example we need to pass the /schedule string as part of a GET parameter, since there isn't a domain name, server nor anything fancy set up.).

  • This is a great start but it only works for domain.com?q=/schedule whereas I'd like it to work for domain.com/schedule. However when I currently go to domain.com/schedule it correctly says there is no such directory. How can I get that to redirect to my index.html?
    – donkey
    Nov 30, 2021 at 2:05
  • The most simple solution I can think of is defining an alias. Something like Alias /schedule "/var/www/", where /var/www/ is your current DocumentRoot should work. It basically calls the same directory index, though you should be careful with all your relative paths.
    – ahpoblete
    Nov 30, 2021 at 6:14
  • Where would I define said alias?
    – donkey
    Feb 18 at 2:31
  • Either in your httpd.conf or in your virtual host's conf file, preferably before it's corresponding <Directory> section. For example: Alias "/schedule" "/var/www" <Directory "/var/www"> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory>
    – ahpoblete
    Feb 18 at 8:12

At Apache server you can create rewrite rule for rendering the same index.html from another path, but displaying the pop-up widget is something you have to solve at application side (eg. JavaScript can use Web API URL.pathname to detect visiting the domain.com/schedule URL). When your application detects that user visited domain.com/schedule (based on pathname), it can call pop-up widget opening action.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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