Forums

[resolved] htaccess edit for vcf / vcard downloading (10 posts)

  1. hollak
    Member
    Posted 1 year ago #

    Hello WordPress geniuses,

    I want to offer my vCard for download on my blog by clicking on an icon. Unfortunately when you click on the icon it offers up the simple txt of the vCard instead of offering a download window like other files (.pdf or .zip).

    I've read that I can edit my .htaccess file with one line of code in order to instruct the server to treat the .vcf file like a .zip file. Here is the code I have found to add to the .htaccess file:

    AddType application/octet-stream vcf

    Trouble is, I have no idea where in the .htaccess file to add this one line of code without breaking anything.

    My .htaccess code current reads:

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

    # END WordPress

    Any help would be greatly appreciated. Where would I add the one line of code?

  2. moshu
    Member
    Posted 1 year ago #

    Anything else should always be outside of the
    # BEGIN WordPress
    ...
    # END WordPress
    portion!

  3. hollak
    Member
    Posted 1 year ago #

    @ moshu:

    Thanks for the reply. Lemme go try it (with fingers crossed).

    If this works, I will be sure to close out the question as resolved.

  4. hollak
    Member
    Posted 1 year ago #

    Well, the good news is that the one line of code added to my .htaccess file didn't break anything (thanks moshu).

    Unfortunately, the code:

    AddType application/octet-stream vcf

    doesn't fix my problem of wanting a .vcf file treated like a .pdf file forcing a download window to appear. It still just goes to the simple text of a .vcf file in a browser window.

    Anyone have a solution?

  5. Otto42
    Moderator
    Posted 1 year ago #

    Make sure you put it at the top of the .htaccess file. Dunno if it will work at the bottom.

  6. hollak
    Member
    Posted 1 year ago #

    @Otto42:

    Thank you. I'll try that.

    I can't be the only person to want to offer up a .vcf inside of a WordPress page. Somebody has this figured out.

    Thank you, off to give the line of code a try at the top.

  7. hollak
    Member
    Posted 1 year ago #

    @ Otto42 & moshu:

    A big thank you to both of you.

    Moving the line of code to the top of the .htaccess file worked. I had it at the bottom. Thanks guys.

    So if anyone else runs across this problem, here is the .htaccess that forced the .vcf file to be treated like a .pdf and open a download window:

    AddType application/octet-stream vcf

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

    # END WordPress

  8. myrealtorjake
    Member
    Posted 10 months ago #

    Thanks to everyone, this was just what I was looking for and incredibly helpful!

  9. feargall
    Member
    Posted 4 months ago #

    hollak,

    I am pretty new to wordpress so apologies in advance if this is a simple question. Can you let me know where you hosted your vcf file for this to function? did you just embed a vcf image in a page with an href to the location to get this to work?

    Thanks

  10. WraithKenny
    Member
    Posted 3 weeks ago #

    @feargall that code should work with any vcf file at the same level as the .htaccess file or any folder or or subfolder within that directory.

Topic Closed

This topic has been closed to new replies.

About this Topic