• I’m trying to create a button or a link on my WordPress site for a .exe file. I have the following in the text section of the page:

    <a href="/home2/projecttoday/public_html/SELMS-setup.exe"> Click Here</a>

    When I click on the link, I get “404 Page Not Found”.

    When I display File Manager for the site there is a file called SELMS-setup.exe in /home2/projecttoday/public_html. So what am I doing wrong? How can I debug this?

Viewing 15 replies - 1 through 15 (of 41 total)
  • Hello,

    You can put the ‘.exe’ file somewhere outside of WordPress on your hosting space, such as in the root directory. Then you can create a link and point to that particular file. For example:

    <a href="path-to-exe-file"> The Text to display </a>

    It would probably be better if you edited the initial post and mark the code snippet specifically as code by putting back-ticks or simply using the code button in the editor.

    It’s possible that your hosting company has put a restriction on direct download of executable files. This way they may heavily reduce the risk that their server might be distributing malware or drive-by infections.

    An initial check you could do would be to have a look at your .htaccess file(s).

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    Your link is to “/home2/projecttoday/public_html/SELMS-setup.exe”.

    You probably want to link to “/SELMS-setup.exe” instead. The local path and your URL paths are not the same thing.

    Thread Starter projecttoday

    (@projecttoday)

    Thanks for responding.

    The code in my post is marked and always was.

    I tried changing it to:

    <a href="/SELMS-setup.exe"> Click Here</a>

    which produced the same error.

    My host provider is HostGator. If this type of file is forbidden by them, wouldn’t I get a message saying so?

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    Actually, I fixed your original post for you to add the backticks around your code. ??

    Make sure the file is web accessible, otherwise your webserver won’t be able to see it. It should probably have permissions of at least 440, or possibly 444 depending on the webserver’s configuration.

    Thread Starter projecttoday

    (@projecttoday)

    Thank you for fixing the post.

    These are the permissions of the file:

    Read: User, Group, World
    Write: User
    Execute: User, Group, World
    Permission: 7,5,5

    To make sure that you’re pointing to the right URL, you could try to put a .txt file and point to it to see if the file type triggers this behavior.

    Thread Starter projecttoday

    (@projecttoday)

    I get the same result with a .txt file. The file I tested has read permission for user, group, and world.

    Then I think that you’re dealing with the fact that WordPress via some commands in .htaccess tries to handle ALL requests to the directory, where it is located.
    You might consider creating a directory /downloads and then make sure that no rewrites occur in .htaccess for any files in this location.

    For example by adding this in the beginning of your .htaccess:

    # BEGIN exclude directories /download/ and /downloads/ from rewrites
    RewriteEngine On
    RewriteRule ^(downloads|download)($|/) - [L]
    # END exclude directories /download/ and /downloads/ from rewrites
    Moderator bcworkz

    (@bcworkz)

    Tor-Björn’s suggestion of a downloads folder is good, but if your WP install is in public root, the root .htaccess will still apply for the most part. This would be fine regarding the WP section in .htaccess — it rewrites only requests where there is no such named file or folder. It’s possible some other rules in .htccess are interfering. Is there anything else in public root .htaccess besides the WP section that would apply to .txt. or .exe files?

    I don’t think you’ve tried an absolute URL yet. Assuming you’ve added a downloads folder, something like href="httр://www.example.com/downloads/SELMS-setup.txt"

    Thread Starter projecttoday

    (@projecttoday)

    What is .htaccess?

    This is the current contents of .htaccess:

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress

    So you only have the standard WP content in this file, which “hi-jacks” all requests to your domain and points them to the main index.php if no direct match is found.

    If you add the snippet I gave above before this block of WP rewrite rules, then I believe that requests to anything in a folder /downloads/ will be served without rewrites. The key here is the flag [L], meaning Last command, i.e. “stop looking for rewrites”.

    Thread Starter projecttoday

    (@projecttoday)

    As far as an absolute URL goes, doesn’t httр://www.example.com/downloads/ refer to a page? How would I get a .exe file in there?

Viewing 15 replies - 1 through 15 (of 41 total)
  • The topic ‘Download button of .exe file’ is closed to new replies.