I am trying to mask certain folder in a WordPress installation using the Htaccess file. I am aware that there are plugins available to do exactly what I want but, I do not want to add even more plugins that may have overlapping functions.

The result I am trying to achieve is :

from

  1. example.com/wp-include/js/jquery/.......
  2. example.com/assets/themes/........
  3. example.com/assets/themes/parent_theme/......
  4. example.com/wp-admin/admin-ajax.php

to

  1. example.com/lib/js/jquery.......
  2. example.com/assets/layouts/.......
  3. example.com/assets/layouts/main/........
  4. example.com/ajax

I have tried inputting the code as below but, this just breaks WP with A 500 internal error

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteRule ^lib/(.*) /wp-includes/ [QSA,L]
RewriteRule ^assets/layouts/(.*) /assets/themes/ [QSA,L]
RewriteRule ^assets/layouts/main/(.*) /assets/themes/parent_theme/ [QSA,L]
RewriteRule ^ajax /wp-admin/admin-ajax.php [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

I have also tried placing the code as follows but this does not provide any results at all (it does not change the 'wp-include' to 'lib')

# BEGIN Custom URL Folder Rewrites
<IfModule mod_rewrite.c>
RewriteEngine On    
RewriteRule ^lib/(.*) /wp-includes/ [QSA,L]
RewriteRule ^assets/layouts/(.*) /assets/themes/ [QSA,L]
RewriteRule ^assets/layouts/main/(.*) /assets/themes/parent_theme/ [QSA,L]
RewriteRule ^ajax /wp-admin/admin-ajax.php [QSA,L]
</IfModule>
# END Custom URL Folder Rewrites

I would be grateful for any help in solving this problem without the use of an additional function heavy plugin.

This WP installation does not use the standard wp-content folder but a custom folder 'assets'

I would also like to be able to use the code outside of the BEGIN WordPress and END WordPress tags so that I have full control and WP does not remove or edit them.

  • It looks like you would run a big risk of collisions with that remapping scheme. – Andy Macaulay-Brook Jul 25 '16 at 13:20
  • I know that this is possible using a plugin 'hide my wp' but, I do not want to add more plugins and the features of that plugin overlap a plugin that I am currently using and does cause issues. – nomad Jul 25 '16 at 13:29

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.