How to add parameters to my htaccess in wordpress to make files open in browser instead of download?

148 Views Asked by At

I want to add the following...

AddType: application/pdf
AddType: application/doc
AddType: application/docx
AddType: application/ppt
AddType: application/ppptx
AddType: application/pps
AddType: application/ppsx
AddType: application/odt
AddType: application/xls
AddType: application/xlsx
AddType: application/rar
AddType: application/zip

...to the htaccess code below, so files uploaded by users on my site will open in the browser instead of automatically downloading. I keep getting errors when I add this to the htaccess code in wordpress:

# 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
1

There are 1 best solutions below

0
Shankaranand On

If you are using the APACHE SERVER instead of the XAMPP ,LAMP OR WAMP etc then you need to follow these steps. Here is the solutions.

Step -1 : Run this command. sudo apt-get install libapache2-mod-php5

Step -2: Enable it. sudo a2enmod php5

Step-3 : Restart apache. sudo service apache2 restart After installing, your website will work properly.

Note: if this is not fulfil your requirement then please share the which server you are using then I can also give a suitable solution. Thanks,