Lin Pro's picture


A working wordpress appliance has an .htaccess file dropped in /var/www/wordpress, which works fine. It is just a:

# BEGIN WordPress
<IfModule mod_rewrite.c>
[and so on and on.......]
# END WordPress

Now, how to repeat that withinin tkldev so every new build contains that mod_rewrite snippet?

Should a file of type mod_rewrite.conf be created in
and the above content be just repeated there?

Putting some code into conf.d/main within wordpress produced the intended behaviour but is it the most efficient way to do so?
Here is what has been tried in conf.d/main:

touch $WPROOT/.htaccess
cat > $WPROOT/.htaccess << EOF
[here comes the code]

chown www-data:www-data $WPROOT/.htaccess

Any help will be greatly appreciated
Lin Pro

Jeremy Davis's picture

.htaccess files are simply Apache config; but just for that directory tree. On a TurnKey appliance that is only hosting a single piece of software (e.g. WordPress) IMO it makes more sense to put that into the general Apache site config rather than the web root.However you can keep it as a .htaccess file if you'd rather.

TurnKey includes mod rewrite (IIRC it is enabled by default in the WP app) so definitely don't put a mod_rewrite.conf in /turnkey/fab/common/overlays/apache/etc/apache2/mods-available/. That will overwrite the existing rewrite module (that comes from package management)!

So personally I would edit the default WordPress Apache config file (to include your snippet). IIRC it's /turnkey/products/wordpress/overlay/etc/apache2/sites-avaialble/wordpress.conf). If you would rather just stick with the .htaccess file then add that to /turnkey/products/wordpress/overlay/var/www/wordpress/. You may still need to chown it from the conf.d script too though.

Add new comment