Publishing VuePress projects using Apache

Last update: 6/12/2021

In case you are not interested in following the suggestions from deployment sectionopen in new window VuePress guide and wish to publish your static website built using VuePress using Apache, or in case you are stuck on shared hosting and have no option, use the following .htaccess.

Place the .htaccess file below into .vuepress/public folder to have it copied to your dist folder automatically. Then copy the contents of .vuepress/dist to your Apache public_html. Make sure to have the mod_rewrite enabled!

DirectoryIndex index.html

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

# You can also add other RewriteRules around here
# Redirect 301 /oldurl /a-new-url.html

RewriteRule ^index\.html$ - [L]
ErrorDocument 404 /404.html

# Do not redirect everything else to index, otherwise no 404 will be triggered
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule . /index.html [L]
</IfModule>