What is the recommended way to include a standard header/footer on a static html website?

StackOverflow https://stackoverflow.com/questions/20961201

سؤال

I have a website (Apache) that is all static html and I want to include certain content across all pages, for example a footer. Are good 'ol server side includes (SSI) still the way to go?

هل كانت مفيدة؟

المحلول

Yes, that will be the simplest solution in this case, just follow the security tips for SSI at http://httpd.apache.org/docs/current/misc/security_tips.html

نصائح أخرى

I wouldn't use SSI's anymore, they are vulnerable to security leaks. It's also a lot easier to just include static HTML with whatever servers side language you're using (PHP, Node.JS, JSP, or whatever), as they allow for a lot more extensibility

Because that would break some links, you could use this in your .htaccess to redirect those links

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\.html$ $1.php?%{QUERY_STRING} [L]
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top