Home › Forums › WordPress Plugins › Hide My WP › not sure why nginx rewrite is not performed
- This topic has 15 replies, 2 voices, and was last updated 7 years, 9 months ago by
Suman M..
-
AuthorPosts
-
October 2, 2017 at 7:54 pm #18174
I want to perform a few rewrites:
this actually works:
rewrite ^/includes/(.*) /wordpress/wp-includes/$1?putyo_happybits=administrator last;
and I get this: http://everhide.wordpress.dev/includes/css/dashicons.min.css?ver=4.8.2 (wp-includes are changed to includes)
I also want to do the same for uploads:
rewrite ^/files/(.*) http:/everhide.wordpress.dev/content/uploads/$1?putyo_happybits=administrator last;
Can not wrap my head around why this does not work.
October 3, 2017 at 4:54 am #18184This reply has been marked as private.October 4, 2017 at 12:28 pm #18197This is what plugin actually suggests:
rewrite ^/files/(.*) /wordpress/http:/everhide.wordpress.dev/content/uploads/$1?putyo_happybits=administrator last;
rewrite ^/modules/(.*) /wordpress/http:/everhide.wordpress.dev/content/plugins/$1?putyo_happybits=administrator last;But this is straight away looks like something wrong.
http:/everhide.wordpress.dev/ – is locally on a vagrant machine so not available externally. I still struggle a bit with this as I tried a lot of different variants and still can not make this to work, except for this:
rewrite ^/includes/(.*) /wordpress/wp-includes/$1?putyo_happybits=administrator last;
which works just fine.
October 5, 2017 at 3:33 am #18211So, isn’t the following rule working?
rewrite ^/files/(.*) /wordpress/wp-content/uploads/$1?putyo_happybits=administrator last;It’ll be difficult for us to check as the site is not available live. Can you please post here the HMWP rules generated when clicking on Nginx Configuration button?
October 7, 2017 at 7:35 am #18261Hi, Suman,
I deployed to a custom link so that you could see my problems:
everhide.happybits.lt
This is how nginx looks like:
server {
listen 80;
server_name everhide.happybits.lt;
root /srv/www/clients/everhide/current/public;index index.html index.htm index.php;
charset utf-8;
location / {
# BEGIN Hide My WP
rewrite ^/lib/js/embed\.min\.js /wp-includes/js/wp-embed.min.js?putyo_hide_my_wp=1234 last;
rewrite ^/login /wordpress/wp-login.php?putyo_hide_my_wp=1234 last;
rewrite ^/lib/(.*) /wordpress/wp-includes/$1?putyo_hide_my_wp=1234 last;
rewrite ^/files/(.*) /content/uploads/$1?putyo_hide_my_wp=1234 last;
rewrite ^/modules/(.*) /content/plugins/$1?putyo_hide_my_wp=1234 last;
rewrite ^/template/(.*) /content/themes/storefront/$1?putyo_hide_my_wp=1234 last;
rewrite ^/ajax /wordpress/wp-admin/admin-ajax.php?putyo_hide_my_wp=1234 last;# END Hide My WP
try_files $uri $uri/ /index.php?$query_string;
}location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }access_log off;
error_log /var/log/nginx/everhide-error.log error;sendfile off;
client_max_body_size 100m;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php7.0-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors off;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
fastcgi_read_timeout 180;
}
location ~ /\.ht {
deny all;
}}
This is how wp-config.php is like originally:
<?php
/**
* Set root path.
*/
$rootPath = realpath(__DIR__ . ‘/..’);/**
* Include the Composer autoloader.
*/
include $rootPath . ‘/vendor/autoload.php’;/**
* Set site URL.
*/
$server_url = getenv(‘SITE_URL’);/**
* Define environment.
*/
define(‘APP_ENV’, getenv(‘APP_ENV’));/**
* Set database details.
*/
define(‘DB_NAME’, getenv(‘DB_NAME’));
define(‘DB_USER’, getenv(‘DB_USER’));
define(‘DB_PASSWORD’, getenv(‘DB_PASSWORD’));
define(‘DB_HOST’, getenv(‘DB_HOST’));/**
* Set debug mode.
*/
define(‘WP_DEBUG’, getenv(‘WP_DEBUG’) === ‘true’ ? true : false);/**
* SSL.
*/
define(‘FORCE_SSL_ADMIN’, getenv(‘WP_FORCE_SSL’) === ‘true’ ? true : false);
define(‘FORCE_SSL_LOGIN’, getenv(‘WP_FORCE_SSL’) === ‘true’ ? true : false);if ($_SERVER[‘HTTP_X_FORWARDED_PROTO’] === ‘https’)
{
$_SERVER[‘HTTPS’] = ‘on’;
}/**
* Set custom paths.
* These are required because WordPress is installed in a subdirectory.
*/
define(‘WP_CONTENT_URL’, $server_url . ‘/content’);
define(‘WP_SITEURL’, $server_url . ‘/wordpress’);
define(‘WP_HOME’, $server_url . ‘/’);
define(‘WP_CONTENT_DIR’, __DIR__ . ‘/content’);define( ‘CONCATENATE_SCRIPTS’, false );
// define( ‘SCRIPT_DEBUG’, true );/**
* Usual WordPress stuff – don’t overide the ones you have already.
*/
define(‘DB_CHARSET’, ‘utf8’);
define(‘DB_COLLATE’, ”);// define(“ADMIN_COOKIE_PATH”, “/wordpress/panel”);
/**
* Authentication unique keys and salts.
*
* @link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service
*/
define(‘AUTH_KEY’, ‘put your unique phrase here’);
define(‘SECURE_AUTH_KEY’, ‘put your unique phrase here’);
define(‘LOGGED_IN_KEY’, ‘put your unique phrase here’);
define(‘NONCE_KEY’, ‘put your unique phrase here’);
define(‘AUTH_SALT’, ‘put your unique phrase here’);
define(‘SECURE_AUTH_SALT’, ‘put your unique phrase here’);
define(‘LOGGED_IN_SALT’, ‘put your unique phrase here’);
define(‘NONCE_SALT’, ‘put your unique phrase here’);/**
* WordPress database table prefix.
* Use something other thanwp_
for security.
*/
$table_prefix = getenv(‘DB_PREFIX’);/**
* Absolute path to the WordPress directory.
*/
if (!defined(‘ABSPATH’))
{
define(‘ABSPATH’, dirname(__FILE__) . ‘/’);
}require_once(ABSPATH . ‘wp-settings.php’);
/**
* Start Suzie
*/
suzie();Maybe the problem is that wordpress is in a sub directory?
As you might see the embed file is failing and apart from includes nothing else is changed by the plugin and nginx (plugins to modules, uploads folder to files and etc.)
I have amended a bit nginx configuration suggested by the plugin, original suggestion from the plugin is here:
# BEGIN Hide My WP
rewrite ^/lib/js/embed\.min\.js /wp-includes/js/wp-embed.min.js?putyo_hide_my_wp=1234 last;
rewrite ^/login /wordpress/wordpress/wp-login.php?putyo_hide_my_wp=1234 last;
rewrite ^/lib/(.*) /wordpress/wp-includes/$1?putyo_hide_my_wp=1234 last;
rewrite ^/files/(.*) /wordpress/http:/everhide.happybits.lt/content/uploads/$1?putyo_hide_my_wp=1234 last;
rewrite ^/modules/(.*) /wordpress/http:/everhide.happybits.lt/content/plugins/$1?putyo_hide_my_wp=1234 last;
rewrite ^/template/(.*) /wordpress/http:/everhide.happybits.lt/content/themes/storefront/$1?putyo_hide_my_wp=1234 last;
rewrite ^/ajax /wordpress/wp-admin/admin-ajax.php?putyo_hide_my_wp=1234 last;# END Hide My WP
Please let me know what I could do to make this work.
Thanks.
-
This reply was modified 7 years, 11 months ago by
FunGuy.
October 8, 2017 at 12:21 pm #18276Hi, I could see that you have added HMWP rules within “location { }” block. Please delete HMWP rules from there and add it within “server { }” block (you can add the rules just before the last “}”)
Let us know!October 8, 2017 at 6:49 pm #18282Hi,
I changed to this:
server {
listen 80;
server_name everhide.happybits.lt;
root /srv/www/clients/everhide/current/public;index index.html index.htm index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }access_log off;
error_log /var/log/nginx/everhide-error.log error;sendfile off;
client_max_body_size 100m;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php7.0-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors off;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
fastcgi_read_timeout 180;
}location ~ /\.ht {
deny all;
}# BEGIN Hide My WP
rewrite ^/lib/js/embed\.min\.js /wp-includes/js/wp-embed.min.js?putyo_hide_my_wp=1234 last;
rewrite ^/login /wordpress/wp-login.php?putyo_hide_my_wp=1234 last;
rewrite ^/lib/(.*) /wordpress/wp-includes/$1?putyo_hide_my_wp=1234 last;
rewrite ^/files/(.*) /content/uploads/$1?putyo_hide_my_wp=1234 last;
rewrite ^/modules/(.*) /content/plugins/$1?putyo_hide_my_wp=1234 last;
rewrite ^/template/(.*) /content/themes/storefront/$1?putyo_hide_my_wp=1234 last;
rewrite ^/ajax /wordpress/wp-admin/admin-ajax.php?putyo_hide_my_wp=1234 last;# END Hide My WP
}restarted nginx, but it did not take any effect – you can check in here: everhide.happybits.lt
Maybe any more ideas?
October 9, 2017 at 6:40 am #18286Nginx config looks fine. Can you please let us know your site’s backend login details as private reply so that we can look into it. Thanks!
October 9, 2017 at 8:07 am #18293This reply has been marked as private.October 9, 2017 at 10:39 am #18303This reply has been marked as private.November 18, 2017 at 5:54 pm #18791This reply has been marked as private.November 19, 2017 at 7:19 am #18793This reply has been marked as private.November 21, 2017 at 8:17 pm #18841This reply has been marked as private.November 22, 2017 at 4:50 am #18852The image needs to be in WP Media. I tried to upload but get error – https://www.screencast.com/t/m4BIx7sB
The new plugin path is also working fine now. You can check your site’s page source.
November 25, 2017 at 7:59 pm #18917This reply has been marked as private. -
This reply was modified 7 years, 11 months ago by
-
AuthorPosts
You must be logged in to reply to this topic.