WP Hide & Security Enhancer - Version 1.4.7

Version Description

  • Rewrite changes for many components
  • Rewrite update for admin and login url
  • Typos fix
  • Compatibility for diferent environments, when WordPress deployed in a domain root, a subdirectory, or it's own folder https://codex.wordpress.org/Giving_WordPress_Its_Own_Directory
Download this release

Release Info

Developer nsp-code
Plugin Icon 128x128 WP Hide & Security Enhancer
Version 1.4.7
Comparing to
See all releases

Code changes from version 1.4.6.6 to 1.4.7

include/functions.class.php CHANGED
@@ -746,13 +746,7 @@
746
  $saved_field_data = $this->untrailingslashit_all($saved_field_data);
747
 
748
  $path = !empty($this->wph->default_variables['wordpress_directory']) ? trailingslashit( $this->wph->default_variables['wordpress_directory'] ) : '';
749
- if(is_multisite())
750
- {
751
- $blog_details = get_blog_details( $blog_id );
752
-
753
- $path = ltrim($blog_details->path, '/');
754
- }
755
-
756
  $rewrite_base = !empty($path) ? trailingslashit( $path ) . $saved_field_data : ( !empty($saved_field_data) ? '/' .$saved_field_data : '' );
757
  if( !empty($rewrite_base))
758
  {
@@ -774,13 +768,27 @@
774
  * Return rewrite to base
775
  *
776
  */
777
- function get_rewrite_to_base( $field_data, $left_slash = TRUE, $right_slash = TRUE )
778
  {
779
- global $blog_id;
780
 
781
  $field_data = $this->untrailingslashit_all( $field_data );
782
 
783
- $path = !empty($this->wph->default_variables['site_relative_path']) ? trailingslashit( $this->wph->default_variables['site_relative_path'] ) : '';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
784
 
785
  $rewrite_to_base = !empty($path) ? trailingslashit( $path ) . $field_data : ( !empty( $field_data ) ? '/' . $field_data : '' );
786
  if( !empty($rewrite_to_base))
@@ -1072,20 +1080,26 @@
1072
  update_option('wph_settings', $settings);
1073
  }
1074
 
1075
-
1076
- function get_url_path($url, $is_file_path = FALSE)
 
 
 
 
 
 
 
1077
  {
1078
  if(!$is_file_path)
1079
  $url = trailingslashit( $url );
1080
 
1081
  $url_parse = parse_url( $url );
1082
-
1083
- /*
1084
- $root = isset($url_parse['scheme']) ? $url_parse['scheme'] . '://' : '';
1085
- $root .= isset($url_parse['host']) ? $url_parse['host'] : '';
1086
- */
1087
-
1088
  $path = $url_parse['path'];
 
 
 
 
1089
 
1090
  if(!$is_file_path)
1091
  $path = trailingslashit( $path );
@@ -1131,7 +1145,24 @@
1131
  $value = ltrim(rtrim($value, "/"), "/");
1132
 
1133
  return $value;
1134
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1135
 
1136
 
1137
  /**
746
  $saved_field_data = $this->untrailingslashit_all($saved_field_data);
747
 
748
  $path = !empty($this->wph->default_variables['wordpress_directory']) ? trailingslashit( $this->wph->default_variables['wordpress_directory'] ) : '';
749
+
 
 
 
 
 
 
750
  $rewrite_base = !empty($path) ? trailingslashit( $path ) . $saved_field_data : ( !empty($saved_field_data) ? '/' .$saved_field_data : '' );
751
  if( !empty($rewrite_base))
752
  {
768
  * Return rewrite to base
769
  *
770
  */
771
+ function get_rewrite_to_base( $field_data, $left_slash = TRUE, $right_slash = TRUE, $append_path = '')
772
  {
773
+
774
 
775
  $field_data = $this->untrailingslashit_all( $field_data );
776
 
777
+ $path = '';
778
+ switch($append_path)
779
+ {
780
+ case 'site_path' :
781
+ $path = !empty($this->wph->default_variables['site_relative_path']) ? trailingslashit( $this->wph->default_variables['site_relative_path'] ) : '';
782
+ break;
783
+
784
+ case 'wp_path' :
785
+ $path .= !empty($this->wph->default_variables['wordpress_directory']) ? trailingslashit( $this->wph->default_variables['wordpress_directory'] ) : '';
786
+ break;
787
+ case 'full_path' :
788
+ $path = !empty($this->wph->default_variables['site_relative_path']) ? trailingslashit( $this->wph->default_variables['site_relative_path'] ) : '';
789
+ $path .= !empty($this->wph->default_variables['wordpress_directory']) ? trailingslashit( $this->wph->default_variables['wordpress_directory'] ) : '';
790
+ break;
791
+ }
792
 
793
  $rewrite_to_base = !empty($path) ? trailingslashit( $path ) . $field_data : ( !empty( $field_data ) ? '/' . $field_data : '' );
794
  if( !empty($rewrite_to_base))
1080
  update_option('wph_settings', $settings);
1081
  }
1082
 
1083
+
1084
+ /**
1085
+ * Get path from url relative to domain root
1086
+ *
1087
+ * @param mixed $url
1088
+ * @param mixed $is_file_path
1089
+ * @param mixed $relative_to_wordpress_directory
1090
+ */
1091
+ function get_url_path($url, $is_file_path = FALSE, $relative_to_wordpress_directory = FALSE)
1092
  {
1093
  if(!$is_file_path)
1094
  $url = trailingslashit( $url );
1095
 
1096
  $url_parse = parse_url( $url );
1097
+
 
 
 
 
 
1098
  $path = $url_parse['path'];
1099
+ if( $relative_to_wordpress_directory === TRUE && $this->wph->default_variables['wordpress_directory'] != '/')
1100
+ {
1101
+ $path = $this->string_left_replacement( $path , trailingslashit ( $this->wph->default_variables['wordpress_directory'] )) ;
1102
+ }
1103
 
1104
  if(!$is_file_path)
1105
  $path = trailingslashit( $path );
1145
  $value = ltrim(rtrim($value, "/"), "/");
1146
 
1147
  return $value;
1148
+ }
1149
+
1150
+ /**
1151
+ * Replace a prefix from the beginning of a text
1152
+ *
1153
+ * @param mixed $string
1154
+ * @param mixed $prefix
1155
+ */
1156
+ function string_left_replacement($string, $prefix)
1157
+ {
1158
+ if (substr($string, 0, strlen($prefix)) == $prefix)
1159
+ {
1160
+ $string = (string) substr($string, strlen($prefix));
1161
+ }
1162
+
1163
+ return $string;
1164
+
1165
+ }
1166
 
1167
 
1168
  /**
include/update.class.php CHANGED
@@ -185,6 +185,15 @@
185
  $_trigger_flush_rules = TRUE;
186
 
187
  $version = '1.4.4.4';
 
 
 
 
 
 
 
 
 
188
  }
189
 
190
 
185
  $_trigger_flush_rules = TRUE;
186
 
187
  $version = '1.4.4.4';
188
+ }
189
+
190
+
191
+ if(version_compare($version, '1.4.7', '<'))
192
+ {
193
+
194
+ $_trigger_flush_rules = TRUE;
195
+
196
+ $version = '1.4.7';
197
  }
198
 
199
 
include/wph.class.php CHANGED
@@ -718,7 +718,6 @@
718
 
719
  $_environment_variable['cache_path'] = str_replace( '\\', '/', WPH_CACHE_PATH);
720
 
721
- $_environment_variable['site_wordpress_relative_path'] = $this->default_variables['site_wordpress_relative_path'];
722
  $_environment_variable['wordpress_directory'] = $this->default_variables['wordpress_directory'];
723
  $_environment_variable['site_relative_path'] = $this->default_variables['site_relative_path'];
724
 
@@ -1104,36 +1103,9 @@
1104
  $wp_upload_dir = wp_upload_dir();
1105
  $this->default_variables['upload_url'] = $wp_upload_dir['baseurl'];
1106
 
1107
- //used across modules
1108
- $this->default_variables['site_wordpress_relative_path'] = $this->functions->get_url_path( rtrim( network_site_url(), '/' ));
1109
-
1110
- //themes url
1111
- $this->templates_data['themes_url'] = trailingslashit( get_theme_root_uri() );
1112
-
1113
- $all_templates = $this->functions->get_themes();
1114
- $all_templates = $this->functions->parse_themes_headers($all_templates);
1115
-
1116
- $stylesheet = get_option( 'stylesheet' );
1117
-
1118
- $this->templates_data['use_child_theme'] = $this->functions->is_child_theme($stylesheet, $all_templates);
1119
-
1120
- $main_theme_directory = $this->functions->get_main_theme_directory($stylesheet, $all_templates);
1121
- $this->templates_data['main'] = array();
1122
- $this->templates_data['main']['folder_name'] = $main_theme_directory;
1123
- $this->templates_data['_template_' . $main_theme_directory] = 'main';
1124
-
1125
- if($this->templates_data['use_child_theme'])
1126
- {
1127
- $this->templates_data['child'] = array();
1128
- $this->templates_data['child']['folder_name'] = $stylesheet;
1129
- $this->templates_data['_template_' . $stylesheet] = 'child';
1130
- }
1131
-
1132
  //catch the absolute siteurl in case wp folder is different than domain root
1133
  $this->default_variables['wordpress_directory'] = '';
1134
  $this->default_variables['content_directory'] = '';
1135
- $this->default_variables['plugins_directory'] = '';
1136
-
1137
 
1138
  //content_directory
1139
  $content_directory = str_replace(ABSPATH, "", WP_CONTENT_DIR);
@@ -1154,19 +1126,49 @@
1154
  {
1155
  $this->default_variables['wordpress_directory'] = '/' . trim($wp_directory, '/');
1156
 
 
1157
  $domain_ABSPATH = str_replace('/' . $wp_directory .'/' , "", trailingslashit( str_replace('\\', '/', realpath( ABSPATH ))));
1158
 
1159
  $content_directory = str_replace($domain_ABSPATH, "" , untrailingslashit( str_replace('\\', '/', realpath( WP_CONTENT_DIR ))));
1160
  $content_directory = trim($content_directory, '/ ');
1161
  $this->default_variables['content_directory'] = '/' . $content_directory;
 
1162
  }
1163
 
1164
- if( !empty($this->default_variables['wordpress_directory']))
1165
- $site_relative_path = str_replace($this->default_variables['wordpress_directory'] .'/' , "", $this->default_variables['site_wordpress_relative_path'] .'/');
 
 
1166
  else
1167
- $site_relative_path = $this->default_variables['site_wordpress_relative_path'] .'/';
1168
- $this->default_variables['site_relative_path'] = rtrim($site_relative_path, '/');
 
 
 
1169
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1170
  }
1171
 
1172
 
718
 
719
  $_environment_variable['cache_path'] = str_replace( '\\', '/', WPH_CACHE_PATH);
720
 
 
721
  $_environment_variable['wordpress_directory'] = $this->default_variables['wordpress_directory'];
722
  $_environment_variable['site_relative_path'] = $this->default_variables['site_relative_path'];
723
 
1103
  $wp_upload_dir = wp_upload_dir();
1104
  $this->default_variables['upload_url'] = $wp_upload_dir['baseurl'];
1105
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1106
  //catch the absolute siteurl in case wp folder is different than domain root
1107
  $this->default_variables['wordpress_directory'] = '';
1108
  $this->default_variables['content_directory'] = '';
 
 
1109
 
1110
  //content_directory
1111
  $content_directory = str_replace(ABSPATH, "", WP_CONTENT_DIR);
1126
  {
1127
  $this->default_variables['wordpress_directory'] = '/' . trim($wp_directory, '/');
1128
 
1129
+ /*
1130
  $domain_ABSPATH = str_replace('/' . $wp_directory .'/' , "", trailingslashit( str_replace('\\', '/', realpath( ABSPATH ))));
1131
 
1132
  $content_directory = str_replace($domain_ABSPATH, "" , untrailingslashit( str_replace('\\', '/', realpath( WP_CONTENT_DIR ))));
1133
  $content_directory = trim($content_directory, '/ ');
1134
  $this->default_variables['content_directory'] = '/' . $content_directory;
1135
+ */
1136
  }
1137
 
1138
+ //used across modules
1139
+ $home_root = parse_url(home_url());
1140
+ if ( isset( $home_root['path'] ) )
1141
+ $home_root_path = trailingslashit($home_root['path']);
1142
  else
1143
+ $home_root_path = '/';
1144
+ $this->default_variables['site_relative_path'] = $home_root_path;
1145
+ //$this->default_variables['site_relative_path'] = rtrim ( $this->functions->get_url_path( rtrim( $siteurl, '/' ), FALSE, FALSE), '/' );
1146
+ if ( empty ( $this->default_variables['site_relative_path'] ) )
1147
+ $this->default_variables['site_relative_path'] = '/';
1148
 
1149
+ //themes url
1150
+ $this->templates_data['themes_url'] = trailingslashit( get_theme_root_uri() );
1151
+
1152
+ $all_templates = $this->functions->get_themes();
1153
+ $all_templates = $this->functions->parse_themes_headers($all_templates);
1154
+
1155
+ $stylesheet = get_option( 'stylesheet' );
1156
+
1157
+ $this->templates_data['use_child_theme'] = $this->functions->is_child_theme($stylesheet, $all_templates);
1158
+
1159
+ $main_theme_directory = $this->functions->get_main_theme_directory($stylesheet, $all_templates);
1160
+ $this->templates_data['main'] = array();
1161
+ $this->templates_data['main']['folder_name'] = $main_theme_directory;
1162
+ $this->templates_data['_template_' . $main_theme_directory] = 'main';
1163
+
1164
+ if($this->templates_data['use_child_theme'])
1165
+ {
1166
+ $this->templates_data['child'] = array();
1167
+ $this->templates_data['child']['folder_name'] = $stylesheet;
1168
+ $this->templates_data['_template_' . $stylesheet] = 'child';
1169
+ }
1170
+
1171
+
1172
  }
1173
 
1174
 
modules/components/admin-admin_url.php CHANGED
@@ -73,16 +73,9 @@
73
 
74
  //add replacement
75
  $this->wph->functions->add_replacement( $default_url, $new_url);
76
-
77
- //add_filter('admin_url', array($this,'admin_url'), 999, 3 );
78
  add_action('set_auth_cookie', array($this,'set_auth_cookie'), 999, 5);
79
 
80
- //?????
81
- //add_filter('style_loader_src', array($this->wph, 'generic_string_replacement' ), 999);
82
-
83
- //add_filter('wp_default_scripts', array($this, 'wp_default_scripts' ), 999);
84
-
85
-
86
  //make sure the admin url redirect url is updated when updating WordPress Core
87
  add_filter('user_admin_url', array($this, 'wp_core_update_user_admin_url'), 999, 2);
88
  add_filter('admin_url', array($this, 'wp_core_update_admin_url'), 999, 3);
@@ -96,14 +89,18 @@
96
  //check if the field is noe empty
97
  if(empty($saved_field_data))
98
  return $processing_response;
 
 
 
99
 
100
  $rewrite_base = $this->wph->functions->get_rewrite_base( $saved_field_data, FALSE, FALSE );
101
- $rewrite_to = $this->wph->functions->get_rewrite_to_base( 'wp-admin', TRUE, FALSE );
 
102
 
103
  if($this->wph->server_htaccess_config === TRUE)
104
  {
105
- $text = "\nRewriteCond %{REQUEST_URI} ". $rewrite_base ."$";
106
- $text .= "\nRewriteRule ^(.*)$ ". $rewrite_base ."/ [R=301,L]";
107
  $text .= "\nRewriteRule ^" . $rewrite_base . '(.*) '. $rewrite_to .'$1 [L,QSA]';
108
  }
109
 
@@ -112,9 +109,9 @@
112
  <rule name="wph-admin_url1" stopProcessing="true">
113
  <match url="^(.*)$" />
114
  <conditions>
115
- <add input="{REQUEST_URI}" matchType="Pattern" pattern="'. $rewrite_base .'$" />
116
  </conditions>
117
- <action type="Redirect" redirectType="Permanent" url="'. $rewrite_base . '{R:1}/" />
118
  </rule>
119
  <rule name="wph-admin_url2" stopProcessing="true">
120
  <match url="^'. $rewrite_base .'(.*)" />
@@ -170,31 +167,7 @@
170
  $logged_in_cookie = wp_generate_auth_cookie( $user_id, $expiration, 'logged_in', $token );
171
 
172
  }
173
-
174
- function wp_default_scripts($scripts)
175
- {
176
- //check if custom admin url is set
177
- $admin_url = $this->wph->functions->get_module_item_setting('admin_url');
178
- if (empty( $admin_url ))
179
- return;
180
-
181
- //update default dirs
182
- if(isset($scripts->default_dirs))
183
- {
184
- foreach($scripts->default_dirs as $key => $value)
185
- {
186
- $scripts->default_dirs[$key] = str_replace('wp-admin', $admin_url, $value);
187
- }
188
- }
189
-
190
- foreach($scripts->registered as $script_name => $script_data)
191
- {
192
- $script_data->src = str_replace('wp-admin', $admin_url, $script_data->src);
193
-
194
- $scripts->registered[$script_name] = $script_data;
195
- }
196
- }
197
-
198
 
199
  function new_url_email_nottice($new_url)
200
  {
@@ -232,69 +205,37 @@
232
  $admin_url = $this->wph->functions->get_module_item_setting('admin_url');
233
  if (empty( $admin_url ))
234
  return FALSE;
235
-
236
- $site_index = $this->wph->functions->get_url_path ( trailingslashit( site_url() ) . 'index.php', TRUE );
237
 
238
  $rewrite_base = $this->wph->functions->get_rewrite_base( '', FALSE);
 
239
 
240
  if($this->wph->server_htaccess_config === TRUE)
241
  {
242
- $text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
243
- $text .= "RewriteRule ^" . $rewrite_base ."wp-admin(.+) $site_index?wph-throw-404 [L]\n";
244
  $text .= "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
245
-
246
- //theme my login usage
247
- //$text .= "RewriteRule ^login(.+) $site_index?throw_404 [L]\n";
248
- //$text .= "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
249
-
250
- $text .= "RewriteRule ^dashboard(.+) $site_index?wph-throw-404 [L]\n";
251
  $text .= "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
252
- $text .= "RewriteRule ^admin(.+) $site_index?wph-throw-404 [L]\n";
253
-
254
- if(!empty($rewrite_base))
255
- {
256
- $text .= "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
257
- $text .= "RewriteRule ^".$rewrite_base."wp-admin(.+) $site_index?wph-throw-404 [L]\n";
258
- $text .= "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
259
- $text .= "RewriteRule ^".$rewrite_base."dashboard(.+) $site_index?wph-throw-404 [L]\n";
260
- $text .= "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
261
- $text .= "RewriteRule ^".$rewrite_base."admin(.+) $site_index?wph-throw-404 [L]";
262
- }
263
  }
264
 
265
  if($this->wph->server_web_config === TRUE)
266
  {
267
- $text = '
268
- <rule name="wph-block_default_admin_url1" stopProcessing="true">
269
- <match url="^'. $rewrite_base .'wp-admin(.+)" />
270
- <action type="Rewrite" url="'. $site_index .'?wph-throw-404" />
271
- </rule>
272
- <rule name="wph-block_default_admin_url2" stopProcessing="true">
273
- <match url="^dashboard(.+)" />
274
- <action type="Rewrite" url="'. $site_index .'?wph-throw-404" />
275
- </rule>
276
- <rule name="wph-block_default_admin_url3" stopProcessing="true">
277
- <match url="^admin(.+)" />
278
- <action type="Rewrite" url="'. $site_index .'?wph-throw-404" />
279
- </rule>
280
- ';
281
- if(!empty($rewrite_base))
282
- {
283
- $text .= '
284
  <rule name="wph-block_default_admin_url4" stopProcessing="true">
285
  <match url="^'. $rewrite_base .'wp-admin(.+)" />
286
- <action type="Rewrite" url="'. $site_index .'?wph-throw-404" />
287
  </rule>
288
  <rule name="wph-block_default_admin_url5" stopProcessing="true">
289
  <match url="^'. $rewrite_base .'dashboard(.+)" />
290
- <action type="Rewrite" url="'. $site_index .'?wph-throw-404" />
291
  </rule>
292
  <rule name="wph-block_default_admin_url6" stopProcessing="true">
293
  <match url="^'. $rewrite_base .'admin(.+)" />
294
- <action type="Rewrite" url="'. $site_index .'?wph-throw-404" />
295
  </rule>
296
- ';
297
- }
298
 
299
 
300
  }
73
 
74
  //add replacement
75
  $this->wph->functions->add_replacement( $default_url, $new_url);
76
+
 
77
  add_action('set_auth_cookie', array($this,'set_auth_cookie'), 999, 5);
78
 
 
 
 
 
 
 
79
  //make sure the admin url redirect url is updated when updating WordPress Core
80
  add_filter('user_admin_url', array($this, 'wp_core_update_user_admin_url'), 999, 2);
81
  add_filter('admin_url', array($this, 'wp_core_update_admin_url'), 999, 3);
89
  //check if the field is noe empty
90
  if(empty($saved_field_data))
91
  return $processing_response;
92
+
93
+ $wp_admin = untrailingslashit ( $this->wph->functions->get_url_path( trailingslashit( site_url() ) . 'wp-admin' ) );
94
+ $new_admin = untrailingslashit ( $this->wph->functions->get_url_path( trailingslashit( site_url() ) . $saved_field_data ) );
95
 
96
  $rewrite_base = $this->wph->functions->get_rewrite_base( $saved_field_data, FALSE, FALSE );
97
+ $rewrite_to = $this->wph->functions->get_rewrite_to_base( $wp_admin, TRUE, FALSE );
98
+ $rewrite_to_new_admin = $this->wph->functions->get_rewrite_to_base( $new_admin, FALSE, FALSE );
99
 
100
  if($this->wph->server_htaccess_config === TRUE)
101
  {
102
+ $text = "\nRewriteCond %{REQUEST_URI} /". $rewrite_to_new_admin ."$";
103
+ $text .= "\nRewriteRule ^(.*)$ /". $rewrite_to_new_admin ."/ [R=301,L]";
104
  $text .= "\nRewriteRule ^" . $rewrite_base . '(.*) '. $rewrite_to .'$1 [L,QSA]';
105
  }
106
 
109
  <rule name="wph-admin_url1" stopProcessing="true">
110
  <match url="^(.*)$" />
111
  <conditions>
112
+ <add input="{REQUEST_URI}" matchType="Pattern" pattern="'. $rewrite_to_new_admin .'$" />
113
  </conditions>
114
+ <action type="Redirect" redirectType="Permanent" url="/'. $rewrite_to_new_admin . '{R:1}/" />
115
  </rule>
116
  <rule name="wph-admin_url2" stopProcessing="true">
117
  <match url="^'. $rewrite_base .'(.*)" />
167
  $logged_in_cookie = wp_generate_auth_cookie( $user_id, $expiration, 'logged_in', $token );
168
 
169
  }
170
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
171
 
172
  function new_url_email_nottice($new_url)
173
  {
205
  $admin_url = $this->wph->functions->get_module_item_setting('admin_url');
206
  if (empty( $admin_url ))
207
  return FALSE;
 
 
208
 
209
  $rewrite_base = $this->wph->functions->get_rewrite_base( '', FALSE);
210
+ $rewrite_to = $this->wph->functions->get_rewrite_to_base( 'index.php', TRUE, FALSE, 'site_path' );
211
 
212
  if($this->wph->server_htaccess_config === TRUE)
213
  {
214
+
 
215
  $text .= "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
216
+ $text .= "RewriteRule ^".$rewrite_base."wp-admin(.+) ". $rewrite_to ."?wph-throw-404 [L]\n";
 
 
 
 
 
217
  $text .= "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
218
+ $text .= "RewriteRule ^".$rewrite_base."dashboard(.+) ". $rewrite_to ."?wph-throw-404 [L]\n";
219
+ $text .= "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
220
+ $text .= "RewriteRule ^".$rewrite_base."admin(.+) ". $rewrite_to ."?wph-throw-404 [L]";
 
 
 
 
 
 
 
 
221
  }
222
 
223
  if($this->wph->server_web_config === TRUE)
224
  {
225
+ $text .= '
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
226
  <rule name="wph-block_default_admin_url4" stopProcessing="true">
227
  <match url="^'. $rewrite_base .'wp-admin(.+)" />
228
+ <action type="Rewrite" url="'. $rewrite_to .'?wph-throw-404" />
229
  </rule>
230
  <rule name="wph-block_default_admin_url5" stopProcessing="true">
231
  <match url="^'. $rewrite_base .'dashboard(.+)" />
232
+ <action type="Rewrite" url="'. $rewrite_to .'?wph-throw-404" />
233
  </rule>
234
  <rule name="wph-block_default_admin_url6" stopProcessing="true">
235
  <match url="^'. $rewrite_base .'admin(.+)" />
236
+ <action type="Rewrite" url="'. $rewrite_to .'?wph-throw-404" />
237
  </rule>
238
+ ';
 
239
 
240
 
241
  }
modules/components/admin-new_wp_login_php.php CHANGED
@@ -90,12 +90,7 @@
90
  return $processing_response;
91
 
92
  $new_wp_login_php = untrailingslashit ( $this->wph->functions->get_url_path( trailingslashit( site_url() ) . 'wp-login.php' ) );
93
-
94
- $path = '';
95
- if(!empty($this->wph->default_variables['wordpress_directory']))
96
- $path = trailingslashit($this->wph->default_variables['wordpress_directory']);
97
- $path .= $saved_field_data;
98
-
99
  $rewrite_base = $this->wph->functions->get_rewrite_base( $saved_field_data, FALSE, FALSE );
100
  $rewrite_to = $this->wph->functions->get_rewrite_to_base( $new_wp_login_php, TRUE, FALSE );
101
 
@@ -136,7 +131,7 @@
136
 
137
 
138
  $rewrite_base = $this->wph->functions->get_rewrite_base( 'wp-login.php', FALSE, FALSE );
139
- $rewrite_to = $this->wph->functions->get_rewrite_to_base( 'index.php', TRUE, FALSE );
140
 
141
  if($this->wph->server_htaccess_config === TRUE)
142
  {
90
  return $processing_response;
91
 
92
  $new_wp_login_php = untrailingslashit ( $this->wph->functions->get_url_path( trailingslashit( site_url() ) . 'wp-login.php' ) );
93
+
 
 
 
 
 
94
  $rewrite_base = $this->wph->functions->get_rewrite_base( $saved_field_data, FALSE, FALSE );
95
  $rewrite_to = $this->wph->functions->get_rewrite_to_base( $new_wp_login_php, TRUE, FALSE );
96
 
131
 
132
 
133
  $rewrite_base = $this->wph->functions->get_rewrite_base( 'wp-login.php', FALSE, FALSE );
134
+ $rewrite_to = $this->wph->functions->get_rewrite_to_base( 'index.php', TRUE, FALSE, 'site_path' );
135
 
136
  if($this->wph->server_htaccess_config === TRUE)
137
  {
modules/components/general-feed.php CHANGED
@@ -55,11 +55,13 @@
55
 
56
  $rewrite = '';
57
 
 
 
58
  if($this->wph->server_htaccess_config === TRUE)
59
  {
60
  $rewrite .= "\nRewriteCond %{REQUEST_URI} ([^/]+)/(feed|rdf|rss|rss2|atom)/?$ [OR]"
61
  . "\nRewriteCond %{REQUEST_URI} ^/(feed|rdf|rss|rss2|atom)/?$"
62
- . "\nRewriteRule . /index.php?wph-throw-404 [L]";
63
 
64
  }
65
 
55
 
56
  $rewrite = '';
57
 
58
+ $rewrite_to = $this->wph->functions->get_rewrite_to_base( 'index.php', TRUE, FALSE, 'site_path' );
59
+
60
  if($this->wph->server_htaccess_config === TRUE)
61
  {
62
  $rewrite .= "\nRewriteCond %{REQUEST_URI} ([^/]+)/(feed|rdf|rss|rss2|atom)/?$ [OR]"
63
  . "\nRewriteCond %{REQUEST_URI} ^/(feed|rdf|rss|rss2|atom)/?$"
64
+ . "\nRewriteRule . ". $rewrite_to ."?wph-throw-404 [L]";
65
 
66
  }
67
 
modules/components/rewrite-comments.php CHANGED
@@ -68,16 +68,18 @@
68
  if(empty($saved_field_data) || $saved_field_data == 'no')
69
  return FALSE;
70
 
71
- $default_path = $this->wph->functions->get_url_path( trailingslashit(site_url()) . 'wp-comments-post.php', TRUE );
 
 
72
 
73
  if($this->wph->server_htaccess_config === TRUE)
74
- $processing_response['rewrite'] = "\nRewriteRule ^" . $saved_field_data . ' '. $default_path .' [L,QSA]';
75
 
76
  if($this->wph->server_web_config === TRUE)
77
  $processing_response['rewrite'] = '
78
  <rule name="wph-new_wp_comments_post" stopProcessing="true">
79
  <match url="^'. $saved_field_data .'" />
80
- <action type="Rewrite" url="'. $default_path .'" appendQueryString="true" />
81
  </rule>
82
  ';
83
 
@@ -100,18 +102,19 @@
100
  return FALSE;
101
 
102
  $rewrite_base = $this->wph->functions->get_rewrite_base( 'wp-comments-post.php', FALSE, FALSE );
 
103
 
104
  if($this->wph->server_htaccess_config === TRUE)
105
  {
106
  $text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
107
- $text .= "RewriteRule ^" . $rewrite_base ." ". $this->wph->default_variables['site_wordpress_relative_path'] ."index.php [L]";
108
  }
109
 
110
  if($this->wph->server_web_config === TRUE)
111
  $text = '
112
  <rule name="wph-block_wp_comments_post_url" stopProcessing="true">
113
  <match url="^' . $rewrite_base . '" />
114
- <action type="Rewrite" url="'. $this->wph->default_variables['site_wordpress_relative_path'] .'index.php" />
115
  </rule>
116
  ';
117
 
68
  if(empty($saved_field_data) || $saved_field_data == 'no')
69
  return FALSE;
70
 
71
+ $file_path = $this->wph->functions->get_url_path( trailingslashit(site_url()) . 'wp-comments-post.php' );
72
+
73
+ $rewrite_to = $this->wph->functions->get_rewrite_to_base( $file_path, TRUE, FALSE );
74
 
75
  if($this->wph->server_htaccess_config === TRUE)
76
+ $processing_response['rewrite'] = "\nRewriteRule ^" . $saved_field_data . ' '. $rewrite_to .' [L,QSA]';
77
 
78
  if($this->wph->server_web_config === TRUE)
79
  $processing_response['rewrite'] = '
80
  <rule name="wph-new_wp_comments_post" stopProcessing="true">
81
  <match url="^'. $saved_field_data .'" />
82
+ <action type="Rewrite" url="'. $rewrite_to .'" appendQueryString="true" />
83
  </rule>
84
  ';
85
 
102
  return FALSE;
103
 
104
  $rewrite_base = $this->wph->functions->get_rewrite_base( 'wp-comments-post.php', FALSE, FALSE );
105
+ $rewrite_to = $this->wph->functions->get_rewrite_to_base( 'index.php', TRUE, FALSE, 'site_path' );
106
 
107
  if($this->wph->server_htaccess_config === TRUE)
108
  {
109
  $text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
110
+ $text .= "RewriteRule ^" . $rewrite_base ." ". $rewrite_to ."?wph-throw-404 [L]";
111
  }
112
 
113
  if($this->wph->server_web_config === TRUE)
114
  $text = '
115
  <rule name="wph-block_wp_comments_post_url" stopProcessing="true">
116
  <match url="^' . $rewrite_base . '" />
117
+ <action type="Rewrite" url="'. $rewrite_to .'?wph-throw-404" />
118
  </rule>
119
  ';
120
 
modules/components/rewrite-json-rest.php CHANGED
@@ -164,16 +164,18 @@
164
  if(empty($saved_field_data) || $saved_field_data == 'no')
165
  return FALSE;
166
 
 
 
167
  if($this->wph->server_htaccess_config === TRUE)
168
  {
169
- $text = "\nRewriteRule ^wp-json(.+) ". $this->wph->default_variables['site_wordpress_relative_path'] ."index.php?wph-throw-404 [L]";
170
  }
171
 
172
  if($this->wph->server_web_config === TRUE)
173
  $text = '
174
  <rule name="wph-block_json_rest" stopProcessing="true">
175
  <match url="^wp-json" />
176
- <action type="Rewrite" url="'. $this->wph->default_variables['site_wordpress_relative_path'] .'index.php" />
177
  </rule>
178
  ';
179
 
164
  if(empty($saved_field_data) || $saved_field_data == 'no')
165
  return FALSE;
166
 
167
+ $rewrite_to = $this->wph->functions->get_rewrite_to_base( 'index.php', TRUE, FALSE, 'site_path' );
168
+
169
  if($this->wph->server_htaccess_config === TRUE)
170
  {
171
+ $text = "\nRewriteRule ^wp-json(.+) ". $rewrite_to ."?wph-throw-404 [L]";
172
  }
173
 
174
  if($this->wph->server_web_config === TRUE)
175
  $text = '
176
  <rule name="wph-block_json_rest" stopProcessing="true">
177
  <match url="^wp-json" />
178
+ <action type="Rewrite" url="'. $rewrite_to .'" />
179
  </rule>
180
  ';
181
 
modules/components/rewrite-new_include_path.php CHANGED
@@ -155,23 +155,26 @@
155
  $new_include_path = $this->wph->functions->get_module_item_setting('new_include_path');
156
  if (empty( $new_include_path ))
157
  return FALSE;
 
 
 
158
 
159
  if($this->wph->server_htaccess_config === TRUE)
160
  {
161
  $text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
162
  $text .= "RewriteCond %{HTTP_COOKIE} !^.*wordpress_logged_in.*$ [NC]\n";
163
- $text .= "RewriteRule ^wp-includes(.+) ". $this->wph->default_variables['site_wordpress_relative_path'] ."index.php [L]";
164
  }
165
 
166
  if($this->wph->server_web_config === TRUE)
167
  {
168
  $text = '
169
  <rule name="wph-block_wpinclude_url" stopProcessing="true">
170
- <match url="^wp-includes(.+)" />
171
  <conditions>
172
  <add input="{HTTP_COOKIE}" matchType="Pattern" pattern="wordpress_logged_in_[^.]+" negate="true" />
173
  </conditions>
174
- <action type="Rewrite" url="'. $this->wph->default_variables['site_wordpress_relative_path'] .'index.php" />
175
  </rule>
176
  ';
177
 
155
  $new_include_path = $this->wph->functions->get_module_item_setting('new_include_path');
156
  if (empty( $new_include_path ))
157
  return FALSE;
158
+
159
+ $rewrite_base = $this->wph->functions->get_rewrite_base( 'wp-includes', FALSE, FALSE );
160
+ $rewrite_to = $this->wph->functions->get_rewrite_to_base( 'index.php', TRUE, FALSE, 'site_path' );
161
 
162
  if($this->wph->server_htaccess_config === TRUE)
163
  {
164
  $text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
165
  $text .= "RewriteCond %{HTTP_COOKIE} !^.*wordpress_logged_in.*$ [NC]\n";
166
+ $text .= "RewriteRule ^" .$rewrite_base ."(.+) ". $rewrite_to ."?wph-throw-404 [L]";
167
  }
168
 
169
  if($this->wph->server_web_config === TRUE)
170
  {
171
  $text = '
172
  <rule name="wph-block_wpinclude_url" stopProcessing="true">
173
+ <match url="^' .$rewrite_base .'(.+)" />
174
  <conditions>
175
  <add input="{HTTP_COOKIE}" matchType="Pattern" pattern="wordpress_logged_in_[^.]+" negate="true" />
176
  </conditions>
177
+ <action type="Rewrite" url="'. $rewrite_to .'?wph-throw-404" />
178
  </rule>
179
  ';
180
 
modules/components/rewrite-new_plugin_path.php CHANGED
@@ -135,16 +135,14 @@
135
 
136
  $rewrite = '';
137
 
138
- $plugin_path = $this->wph->functions->get_url_path( WP_PLUGIN_URL );
139
 
140
  $path = '';
141
- /*
142
- if(!empty($this->wph->default_variables['wordpress_directory']))
143
- $path = trailingslashit($this->wph->default_variables['wordpress_directory']);
144
- */
145
-
146
  if(!empty($saved_field_data))
147
  $path .= trailingslashit( $saved_field_data );
 
 
148
 
149
 
150
  //add custom rewrite for plugins
@@ -167,15 +165,17 @@
167
  $new_url = trailingslashit( site_url() ) . $plugin_custom_path;
168
  if($path != '/')
169
  $new_url = trailingslashit( $new_url ) . $path;
170
-
 
 
171
  if($this->wph->server_htaccess_config === TRUE)
172
- $rewrite .= "\nRewriteRule ^" . trailingslashit( $plugin_custom_path ) . '(.+) '. trailingslashit($plugin_path) . trailingslashit($active_plugin_directory) .'$1 [L,QSA]';
173
 
174
  if($this->wph->server_web_config === TRUE)
175
  $rewrite .= '
176
  <rule name="wph-new_plugin_path-'. $plugin_slug .'" stopProcessing="true">
177
  <match url="^'. trailingslashit( $plugin_custom_path ) .'(.+)" />
178
- <action type="Rewrite" url="'. trailingslashit($plugin_path) . trailingslashit($active_plugin_directory) .'{R:1}" appendQueryString="true" />
179
  </rule>
180
  ';
181
  }
@@ -183,13 +183,13 @@
183
  if( !empty($path) && !empty($saved_field_data))
184
  {
185
  if($this->wph->server_htaccess_config === TRUE)
186
- $rewrite .= "\nRewriteRule ^" . trailingslashit( $path ) . '(.+) '. $plugin_path .'$1 [L,QSA]';
187
 
188
  if($this->wph->server_web_config === TRUE)
189
  $rewrite .= '
190
  <rule name="wph-new_plugin_path" stopProcessing="true">
191
  <match url="^'. trailingslashit( $path ) .'(.+)" />
192
- <action type="Rewrite" url="'. $plugin_path .'{R:1}" appendQueryString="true" />
193
  </rule>
194
  ';
195
  }
@@ -219,17 +219,19 @@
219
  $default_plugin_url = str_replace( $home_url, "", $default_plugin_url);
220
  $default_plugin_url = ltrim(rtrim($default_plugin_url, "/"), "/");
221
 
 
 
222
  if($this->wph->server_htaccess_config === TRUE)
223
  {
224
  $text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
225
- $text .= "RewriteRule ^". $default_plugin_url ."(.+) ". $this->wph->default_variables['site_wordpress_relative_path'] ."index.php [L]";
226
  }
227
 
228
  if($this->wph->server_web_config === TRUE)
229
  $text = '
230
  <rule name="wph-block_plugins_url" stopProcessing="true">
231
  <match url="^'. $default_plugin_url .'(.+)" />
232
- <action type="Rewrite" url="'. $this->wph->default_variables['site_wordpress_relative_path'] .'index.php" />
233
  </rule>
234
  ';
235
 
135
 
136
  $rewrite = '';
137
 
138
+ $plugin_path = $this->wph->functions->get_url_path( WP_PLUGIN_URL );
139
 
140
  $path = '';
141
+
 
 
 
 
142
  if(!empty($saved_field_data))
143
  $path .= trailingslashit( $saved_field_data );
144
+
145
+ $rewrite_to = $this->wph->functions->get_rewrite_to_base( $plugin_path );
146
 
147
 
148
  //add custom rewrite for plugins
165
  $new_url = trailingslashit( site_url() ) . $plugin_custom_path;
166
  if($path != '/')
167
  $new_url = trailingslashit( $new_url ) . $path;
168
+
169
+ $plugin_rewrite_to = $this->wph->functions->get_rewrite_to_base( trailingslashit($plugin_path) . $active_plugin_directory );
170
+
171
  if($this->wph->server_htaccess_config === TRUE)
172
+ $rewrite .= "\nRewriteRule ^" . trailingslashit( $plugin_custom_path ) . '(.+) '. $plugin_rewrite_to .'$1 [L,QSA]';
173
 
174
  if($this->wph->server_web_config === TRUE)
175
  $rewrite .= '
176
  <rule name="wph-new_plugin_path-'. $plugin_slug .'" stopProcessing="true">
177
  <match url="^'. trailingslashit( $plugin_custom_path ) .'(.+)" />
178
+ <action type="Rewrite" url="'. $plugin_rewrite_to .'{R:1}" appendQueryString="true" />
179
  </rule>
180
  ';
181
  }
183
  if( !empty($path) && !empty($saved_field_data))
184
  {
185
  if($this->wph->server_htaccess_config === TRUE)
186
+ $rewrite .= "\nRewriteRule ^" . trailingslashit( $path ) . '(.+) '. $rewrite_to .'$1 [L,QSA]';
187
 
188
  if($this->wph->server_web_config === TRUE)
189
  $rewrite .= '
190
  <rule name="wph-new_plugin_path" stopProcessing="true">
191
  <match url="^'. trailingslashit( $path ) .'(.+)" />
192
+ <action type="Rewrite" url="'. $rewrite_to .'{R:1}" appendQueryString="true" />
193
  </rule>
194
  ';
195
  }
219
  $default_plugin_url = str_replace( $home_url, "", $default_plugin_url);
220
  $default_plugin_url = ltrim(rtrim($default_plugin_url, "/"), "/");
221
 
222
+ $rewrite_to = $this->wph->functions->get_rewrite_to_base( 'index.php', TRUE, FALSE, 'site_path' );
223
+
224
  if($this->wph->server_htaccess_config === TRUE)
225
  {
226
  $text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
227
+ $text .= "RewriteRule ^". $default_plugin_url ."(.+) ". $rewrite_to ."?wph-throw-404 [L]";
228
  }
229
 
230
  if($this->wph->server_web_config === TRUE)
231
  $text = '
232
  <rule name="wph-block_plugins_url" stopProcessing="true">
233
  <match url="^'. $default_plugin_url .'(.+)" />
234
+ <action type="Rewrite" url="'. $rewrite_to .'?wph-throw-404" />
235
  </rule>
236
  ';
237
 
modules/components/rewrite-new_theme_path.php CHANGED
@@ -161,22 +161,19 @@
161
  $theme_path = $this->wph->functions->get_url_path( $this->wph->templates_data['themes_url'] . $this->wph->templates_data['main']['folder_name'] );
162
 
163
  $path = '';
164
- /*
165
- if(!empty($this->wph->default_variables['wordpress_directory']))
166
- $path = trailingslashit($this->wph->default_variables['wordpress_directory']);
167
- */
168
  $path .= trailingslashit( $saved_field_data );
169
 
170
  $theme_path = str_replace(' ', '%20', $theme_path);
 
171
 
172
  if($this->wph->server_htaccess_config === TRUE)
173
- $processing_response['rewrite'] = "\nRewriteRule ^" . $path . '(.+) '. $theme_path .'$1 [L,QSA]';
174
 
175
  if($this->wph->server_web_config === TRUE)
176
  $processing_response['rewrite'] = '
177
  <rule name="wph-new_theme_path" stopProcessing="true">
178
  <match url="^'. $path .'(.+)" />
179
- <action type="Rewrite" url="'. $theme_path .'{R:1}" appendQueryString="true" />
180
  </rule>
181
  ';
182
 
@@ -207,23 +204,20 @@
207
  $theme_path = $this->wph->functions->get_url_path( $this->wph->templates_data['themes_url'] . $this->wph->templates_data['child']['folder_name'] );
208
 
209
  $path = '';
210
- /*
211
- if(!empty($this->wph->default_variables['wordpress_directory']))
212
- $path = trailingslashit($this->wph->default_variables['wordpress_directory']);
213
- */
214
  $path .= trailingslashit( $saved_field_data );
215
 
216
 
217
  $theme_path = str_replace(' ', '%20', $theme_path);
 
218
 
219
  if($this->wph->server_htaccess_config === TRUE)
220
- $processing_response['rewrite'] = "\nRewriteRule ^" . $path . '(.+) '. $theme_path .'$1 [L,QSA]';
221
 
222
  if($this->wph->server_web_config === TRUE)
223
  $processing_response['rewrite'] = '
224
  <rule name="wph-new_theme_child_path" stopProcessing="true">
225
  <match url="^'. $path .'(.+)" />
226
- <action type="Rewrite" url="'. $theme_path .'{R:1}" appendQueryString="true" />
227
  </rule>
228
  ';
229
 
@@ -298,15 +292,16 @@
298
  }
299
 
300
  $current_stylesheet_uri = str_replace(' ', '%20', $current_stylesheet_uri);
 
301
 
302
  if($this->wph->server_htaccess_config === TRUE)
303
- $processing_response['rewrite'] = "\nRewriteRule ^" . $path . ' '. $current_stylesheet_uri .' [L,QSA]';
304
 
305
  if($this->wph->server_web_config === TRUE)
306
  $processing_response['rewrite'] = '
307
  <rule name="wph-new_style_file_path" stopProcessing="true">
308
  <match url="^'. $path .'" />
309
- <action type="Rewrite" url="'. $current_stylesheet_uri .'" appendQueryString="true" />
310
  </rule>
311
  ';
312
 
@@ -410,9 +405,10 @@
410
 
411
  //plugin File Processor router path
412
  $file_processor = $this->wph->functions->get_url_path( WP_PLUGIN_URL );
413
- $file_processor = trailingslashit( $file_processor ) . 'wp-hide-security-enhancer/router/file-process.php';
414
 
415
  $current_stylesheet_uri = str_replace(' ', '%20', $current_stylesheet_uri);
 
416
  $path = str_replace(' ', '%20', $path);
417
 
418
  $processing_response['rewrite'] = '';
@@ -510,15 +506,16 @@
510
  }
511
 
512
  $current_stylesheet_uri = str_replace(' ', '%20', $current_stylesheet_uri);
 
513
 
514
  if($this->wph->server_htaccess_config === TRUE)
515
- $processing_response['rewrite'] = "\nRewriteRule ^" . $path . ' '. $current_stylesheet_uri .' [L,QSA]';
516
 
517
  if($this->wph->server_web_config === TRUE)
518
  $processing_response['rewrite'] = '
519
  <rule name="wph-child_style_file_path" stopProcessing="true">
520
  <match url="^'. $path .'" />
521
- <action type="Rewrite" url="'. $current_stylesheet_uri .'" appendQueryString="true" />
522
  </rule>
523
  ';
524
 
@@ -616,12 +613,12 @@
616
 
617
  //plugin File Processor router path
618
  $file_processor = $this->wph->functions->get_url_path( WP_PLUGIN_URL );
619
- $file_processor = trailingslashit( $file_processor ) . 'wp-hide-security-enhancer/router/file-process.php';
620
 
621
  $current_stylesheet_uri = str_replace(' ', '%20', $current_stylesheet_uri);
 
622
  $path = str_replace(' ', '%20', $path);
623
 
624
-
625
  $processing_response['rewrite'] = '';
626
  if($this->rewrite_global_output === FALSE)
627
  {
@@ -651,15 +648,14 @@
651
 
652
  $rewrite = '';
653
 
 
 
 
 
 
 
654
  if($this->wph->server_htaccess_config === TRUE)
655
  {
656
- $cache_path = '%{DOCUMENT_ROOT}';
657
- $cache_path .= !empty($this->wph->default_variables['site_relative_path']) ? $this->wph->default_variables['site_relative_path'] : '';
658
- $cache_path .= !empty($this->wph->default_variables['content_directory']) ? $this->wph->default_variables['content_directory'] : '';
659
-
660
- $actual_cache_path = '';
661
- $actual_cache_path .= !empty($this->wph->default_variables['site_relative_path']) ? $this->wph->default_variables['site_relative_path'] : '';
662
- $actual_cache_path .= !empty($this->wph->default_variables['content_directory']) ? $this->wph->default_variables['content_directory'] : '';
663
 
664
  $rewrite = "\n" . 'RewriteCond "' . $cache_path . '/cache/wph/%{HTTP_HOST}%{REQUEST_URI}" -f' ."\n" .
665
  'RewriteRule .* "' . $actual_cache_path . '/cache/wph/%{HTTP_HOST}%{REQUEST_URI}" [L]' ."\n";
@@ -667,14 +663,6 @@
667
 
668
  if($this->wph->server_web_config === TRUE)
669
  {
670
- $cache_path = '{DOCUMENT_ROOT}';
671
- $cache_path .= !empty($this->wph->default_variables['site_relative_path']) ? $this->wph->default_variables['site_relative_path'] : '';
672
- $cache_path .= !empty($this->wph->default_variables['content_directory']) ? $this->wph->default_variables['content_directory'] : '';
673
-
674
- $actual_cache_path = '';
675
- $actual_cache_path .= !empty($this->wph->default_variables['site_relative_path']) ? $this->wph->default_variables['site_relative_path'] : '';
676
- $actual_cache_path .= !empty($this->wph->default_variables['content_directory']) ? $this->wph->default_variables['content_directory'] : '';
677
-
678
  $rewrite = "\n" . '
679
  <rule name="wph_rewrite_global_file_process" stopProcessing="true">
680
  <match url=".*" />
161
  $theme_path = $this->wph->functions->get_url_path( $this->wph->templates_data['themes_url'] . $this->wph->templates_data['main']['folder_name'] );
162
 
163
  $path = '';
 
 
 
 
164
  $path .= trailingslashit( $saved_field_data );
165
 
166
  $theme_path = str_replace(' ', '%20', $theme_path);
167
+ $rewrite_to = $this->wph->functions->get_rewrite_to_base( $theme_path );
168
 
169
  if($this->wph->server_htaccess_config === TRUE)
170
+ $processing_response['rewrite'] = "\nRewriteRule ^" . $path . '(.+) '. $rewrite_to .'$1 [L,QSA]';
171
 
172
  if($this->wph->server_web_config === TRUE)
173
  $processing_response['rewrite'] = '
174
  <rule name="wph-new_theme_path" stopProcessing="true">
175
  <match url="^'. $path .'(.+)" />
176
+ <action type="Rewrite" url="'. $rewrite_to .'{R:1}" appendQueryString="true" />
177
  </rule>
178
  ';
179
 
204
  $theme_path = $this->wph->functions->get_url_path( $this->wph->templates_data['themes_url'] . $this->wph->templates_data['child']['folder_name'] );
205
 
206
  $path = '';
 
 
 
 
207
  $path .= trailingslashit( $saved_field_data );
208
 
209
 
210
  $theme_path = str_replace(' ', '%20', $theme_path);
211
+ $rewrite_to = $this->wph->functions->get_rewrite_to_base( $theme_path );
212
 
213
  if($this->wph->server_htaccess_config === TRUE)
214
+ $processing_response['rewrite'] = "\nRewriteRule ^" . $path . '(.+) '. $rewrite_to .'$1 [L,QSA]';
215
 
216
  if($this->wph->server_web_config === TRUE)
217
  $processing_response['rewrite'] = '
218
  <rule name="wph-new_theme_child_path" stopProcessing="true">
219
  <match url="^'. $path .'(.+)" />
220
+ <action type="Rewrite" url="'. $rewrite_to .'{R:1}" appendQueryString="true" />
221
  </rule>
222
  ';
223
 
292
  }
293
 
294
  $current_stylesheet_uri = str_replace(' ', '%20', $current_stylesheet_uri);
295
+ $rewrite_to = $this->wph->functions->get_rewrite_to_base( $current_stylesheet_uri, TRUE, FALSE );
296
 
297
  if($this->wph->server_htaccess_config === TRUE)
298
+ $processing_response['rewrite'] = "\nRewriteRule ^" . $path . ' '. $rewrite_to .' [L,QSA]';
299
 
300
  if($this->wph->server_web_config === TRUE)
301
  $processing_response['rewrite'] = '
302
  <rule name="wph-new_style_file_path" stopProcessing="true">
303
  <match url="^'. $path .'" />
304
+ <action type="Rewrite" url="'. $rewrite_to .'" appendQueryString="true" />
305
  </rule>
306
  ';
307
 
405
 
406
  //plugin File Processor router path
407
  $file_processor = $this->wph->functions->get_url_path( WP_PLUGIN_URL );
408
+ $file_processor = $this->wph->functions->get_rewrite_to_base( trailingslashit( $file_processor ) . 'wp-hide-security-enhancer/router/file-process.php', TRUE, FALSE );
409
 
410
  $current_stylesheet_uri = str_replace(' ', '%20', $current_stylesheet_uri);
411
+ $current_stylesheet_uri = $this->wph->functions->get_rewrite_to_base( $current_stylesheet_uri, TRUE, FALSE );
412
  $path = str_replace(' ', '%20', $path);
413
 
414
  $processing_response['rewrite'] = '';
506
  }
507
 
508
  $current_stylesheet_uri = str_replace(' ', '%20', $current_stylesheet_uri);
509
+ $rewrite_to = $this->wph->functions->get_rewrite_to_base( $current_stylesheet_uri, TRUE, FALSE );
510
 
511
  if($this->wph->server_htaccess_config === TRUE)
512
+ $processing_response['rewrite'] = "\nRewriteRule ^" . $path . ' '. $rewrite_to .' [L,QSA]';
513
 
514
  if($this->wph->server_web_config === TRUE)
515
  $processing_response['rewrite'] = '
516
  <rule name="wph-child_style_file_path" stopProcessing="true">
517
  <match url="^'. $path .'" />
518
+ <action type="Rewrite" url="'. $rewrite_to .'" appendQueryString="true" />
519
  </rule>
520
  ';
521
 
613
 
614
  //plugin File Processor router path
615
  $file_processor = $this->wph->functions->get_url_path( WP_PLUGIN_URL );
616
+ $file_processor = $this->wph->functions->get_rewrite_to_base( trailingslashit( $file_processor ) . 'wp-hide-security-enhancer/router/file-process.php', TRUE, FALSE );
617
 
618
  $current_stylesheet_uri = str_replace(' ', '%20', $current_stylesheet_uri);
619
+ $current_stylesheet_uri = $this->wph->functions->get_rewrite_to_base( $current_stylesheet_uri, TRUE, FALSE );
620
  $path = str_replace(' ', '%20', $path);
621
 
 
622
  $processing_response['rewrite'] = '';
623
  if($this->rewrite_global_output === FALSE)
624
  {
648
 
649
  $rewrite = '';
650
 
651
+ $cache_path = '%{DOCUMENT_ROOT}';
652
+ $cache_path .= $this->wph->functions->get_rewrite_to_base( $this->wph->default_variables['content_directory'], TRUE, FALSE, 'full_path' );
653
+
654
+ $actual_cache_path = '';
655
+ $actual_cache_path .= $this->wph->functions->get_rewrite_to_base( $this->wph->default_variables['content_directory'], TRUE, FALSE, 'full_path' );
656
+
657
  if($this->wph->server_htaccess_config === TRUE)
658
  {
 
 
 
 
 
 
 
659
 
660
  $rewrite = "\n" . 'RewriteCond "' . $cache_path . '/cache/wph/%{HTTP_HOST}%{REQUEST_URI}" -f' ."\n" .
661
  'RewriteRule .* "' . $actual_cache_path . '/cache/wph/%{HTTP_HOST}%{REQUEST_URI}" [L]' ."\n";
663
 
664
  if($this->wph->server_web_config === TRUE)
665
  {
 
 
 
 
 
 
 
 
666
  $rewrite = "\n" . '
667
  <rule name="wph_rewrite_global_file_process" stopProcessing="true">
668
  <match url=".*" />
modules/components/rewrite-new_upload_path.php CHANGED
@@ -28,7 +28,7 @@
28
  $this->module_settings[] = array(
29
  'id' => 'block_upload_url',
30
  'label' => __('Block uploads URL', 'wp-hide-security-enhancer'),
31
- 'description' => __('Block upload files from being accesible through default urls.', 'wp-hide-security-enhancer') . ' <br />'.__('If set to Yes, all new images inserted into posts will use the new Upload Url, as old url become blocked. Using the No, new images inesrted will use old url, which however are being updated on front side. This may be helpfull on plugin disable, so image urls can be accessible as before.', 'wp-hide-security-enhancer').'<br />'. __('Apply only if', 'wp-hide-security-enhancer') .' <b>New Upload Path</b> '.__('is not empty.', 'wp-hide-security-enhancer'),
32
 
33
  'input_type' => 'radio',
34
  'options' => array(
@@ -164,18 +164,19 @@
164
  $default_upload_url = ltrim(rtrim($default_upload_url, "/"), "/");
165
 
166
  $rewrite_base = $this->wph->functions->get_rewrite_base( $default_upload_url, FALSE );
 
167
 
168
  if($this->wph->server_htaccess_config === TRUE)
169
  {
170
  $text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
171
- $text .= "RewriteRule ^". $rewrite_base ."(.+) ". $this->wph->default_variables['site_wordpress_relative_path'] ."index.php [L]";
172
  }
173
 
174
  if($this->wph->server_web_config === TRUE)
175
  $text = '
176
  <rule name="wph-block_upload_url" stopProcessing="true">
177
  <match url="^'. $rewrite_base .'(.+)" />
178
- <action type="Rewrite" url="'. $this->wph->default_variables['site_wordpress_relative_path'] .'index.php" />
179
  </rule>
180
  ';
181
 
28
  $this->module_settings[] = array(
29
  'id' => 'block_upload_url',
30
  'label' => __('Block uploads URL', 'wp-hide-security-enhancer'),
31
+ 'description' => __('Block upload files from being accesible through default urls.', 'wp-hide-security-enhancer') . ' <br />'.__('If set to Yes, all new images inserted into posts will use the new Upload Url, as old url become blocked. Using the No, new images inserted will use old url, which however are being updated on front side. This may be helpful on plugin disable, so image urls can be accessible as before.', 'wp-hide-security-enhancer').'<br />'. __('Apply only if', 'wp-hide-security-enhancer') .' <b>New Upload Path</b> '.__('is not empty.', 'wp-hide-security-enhancer'),
32
 
33
  'input_type' => 'radio',
34
  'options' => array(
164
  $default_upload_url = ltrim(rtrim($default_upload_url, "/"), "/");
165
 
166
  $rewrite_base = $this->wph->functions->get_rewrite_base( $default_upload_url, FALSE );
167
+ $rewrite_to = $this->wph->functions->get_rewrite_to_base( 'index.php', TRUE, FALSE, 'site_path' );
168
 
169
  if($this->wph->server_htaccess_config === TRUE)
170
  {
171
  $text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
172
+ $text .= "RewriteRule ^". $rewrite_base ."(.+) ". $rewrite_to ."?wph-throw-404 [L]";
173
  }
174
 
175
  if($this->wph->server_web_config === TRUE)
176
  $text = '
177
  <rule name="wph-block_upload_url" stopProcessing="true">
178
  <match url="^'. $rewrite_base .'(.+)" />
179
+ <action type="Rewrite" url="'. $rewrite_to .'?wph-throw-404" />
180
  </rule>
181
  ';
182
 
modules/components/rewrite-new_xml-rpc-path.php CHANGED
@@ -98,15 +98,19 @@
98
  //check if the field is noe empty
99
  if(empty($saved_field_data))
100
  return $processing_response;
 
 
 
 
101
 
102
  if($this->wph->server_htaccess_config === TRUE)
103
- $processing_response['rewrite'] = "\nRewriteRule ^" . $saved_field_data . ' '. $this->wph->default_variables['site_wordpress_relative_path'] .'xmlrpc.php [L,QSA]';
104
 
105
  if($this->wph->server_web_config === TRUE)
106
  $processing_response['rewrite'] = '
107
  <rule name="wph-new_xml_rpc_path" stopProcessing="true">
108
  <match url="^'. $saved_field_data .'" />
109
- <action type="Rewrite" url="'. $this->wph->default_variables['site_wordpress_relative_path'] .'xmlrpc.php" appendQueryString="true" />
110
  </rule>
111
  ';
112
 
@@ -121,17 +125,19 @@
121
  if(empty($saved_field_data) || $saved_field_data == 'no')
122
  return FALSE;
123
 
 
 
124
  if($this->wph->server_htaccess_config === TRUE)
125
  {
126
  $text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
127
- $text .= "RewriteRule ^xmlrpc.php ". $this->wph->default_variables['site_wordpress_relative_path'] ."index.php [L]";
128
  }
129
 
130
  if($this->wph->server_web_config === TRUE)
131
  $text = '
132
  <rule name="wph-block_xml_rpc" stopProcessing="true">
133
  <match url="^xmlrpc.php" />
134
- <action type="Rewrite" url="'. $this->wph->default_variables['site_wordpress_relative_path'] .'index.php" />
135
  </rule>
136
  ';
137
 
98
  //check if the field is noe empty
99
  if(empty($saved_field_data))
100
  return $processing_response;
101
+
102
+ $file_path = $this->wph->functions->get_url_path( trailingslashit(site_url()) . 'xmlrpc.php' );
103
+
104
+ $rewrite_to = $this->wph->functions->get_rewrite_to_base( $file_path, TRUE, FALSE );
105
 
106
  if($this->wph->server_htaccess_config === TRUE)
107
+ $processing_response['rewrite'] = "\nRewriteRule ^" . $saved_field_data . ' '. $rewrite_to .' [L,QSA]';
108
 
109
  if($this->wph->server_web_config === TRUE)
110
  $processing_response['rewrite'] = '
111
  <rule name="wph-new_xml_rpc_path" stopProcessing="true">
112
  <match url="^'. $saved_field_data .'" />
113
+ <action type="Rewrite" url="'. $rewrite_to .'" appendQueryString="true" />
114
  </rule>
115
  ';
116
 
125
  if(empty($saved_field_data) || $saved_field_data == 'no')
126
  return FALSE;
127
 
128
+ $rewrite_to = $this->wph->functions->get_rewrite_to_base( 'index.php', TRUE, FALSE, 'site_path' );
129
+
130
  if($this->wph->server_htaccess_config === TRUE)
131
  {
132
  $text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
133
+ $text .= "RewriteRule ^xmlrpc.php ". $rewrite_to ."?wph-throw-404 [L]";
134
  }
135
 
136
  if($this->wph->server_web_config === TRUE)
137
  $text = '
138
  <rule name="wph-block_xml_rpc" stopProcessing="true">
139
  <match url="^xmlrpc.php" />
140
+ <action type="Rewrite" url="'. $rewrite_to .'?wph-throw-404" />
141
  </rule>
142
  ';
143
 
modules/components/rewrite-root-files.php CHANGED
@@ -142,18 +142,19 @@
142
  return FALSE;
143
 
144
  $rewrite_base = $this->wph->functions->get_rewrite_base( 'license.txt', FALSE, FALSE );
 
145
 
146
  if($this->wph->server_htaccess_config === TRUE)
147
  {
148
  $text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
149
- $text .= "RewriteRule ^" . $rewrite_base ." ". $this->wph->default_variables['site_wordpress_relative_path'] ."index.php [L]";
150
  }
151
 
152
  if($this->wph->server_web_config === TRUE)
153
  $text = '
154
  <rule name="wph-block_license_txt" stopProcessing="true">
155
  <match url="^' . $rewrite_base . '" />
156
- <action type="Rewrite" url="'. $this->wph->default_variables['site_wordpress_relative_path'] .'index.php" />
157
  </rule>
158
  ';
159
 
@@ -172,18 +173,19 @@
172
  return FALSE;
173
 
174
  $rewrite_base = $this->wph->functions->get_rewrite_base( 'readme.html', FALSE, FALSE );
 
175
 
176
  if($this->wph->server_htaccess_config === TRUE)
177
  {
178
  $text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
179
- $text .= "RewriteRule ^" . $rewrite_base ." ". $this->wph->default_variables['site_wordpress_relative_path'] ."index.php [L]";
180
  }
181
 
182
  if($this->wph->server_web_config === TRUE)
183
  $text = '
184
  <rule name="wph-block_readme_html" stopProcessing="true">
185
  <match url="^' . $rewrite_base . '" />
186
- <action type="Rewrite" url="'. $this->wph->default_variables['site_wordpress_relative_path'] .'index.php" />
187
  </rule>
188
  ';
189
 
@@ -202,18 +204,19 @@
202
  return FALSE;
203
 
204
  $rewrite_base = $this->wph->functions->get_rewrite_base( 'wp-activate.php', FALSE, FALSE );
 
205
 
206
  if($this->wph->server_htaccess_config === TRUE)
207
  {
208
  $text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
209
- $text .= "RewriteRule ^" . $rewrite_base ." ". $this->wph->default_variables['site_wordpress_relative_path'] ."index.php [L]";
210
  }
211
 
212
  if($this->wph->server_web_config === TRUE)
213
  $text = '
214
  <rule name="wph-block_wp_activate_php" stopProcessing="true">
215
  <match url="^' . $rewrite_base . '" />
216
- <action type="Rewrite" url="'. $this->wph->default_variables['site_wordpress_relative_path'] .'index.php" />
217
  </rule>
218
  ';
219
 
@@ -233,18 +236,19 @@
233
  return FALSE;
234
 
235
  $rewrite_base = $this->wph->functions->get_rewrite_base( 'wp-cron.php', FALSE, FALSE );
 
236
 
237
  if($this->wph->server_htaccess_config === TRUE)
238
  {
239
  $text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
240
- $text .= "RewriteRule ^" . $rewrite_base ." ". $this->wph->default_variables['site_wordpress_relative_path'] ."index.php [L]";
241
  }
242
 
243
  if($this->wph->server_web_config === TRUE)
244
  $text = '
245
  <rule name="wph-block_wp_cron_php" stopProcessing="true">
246
  <match url="^' . $rewrite_base . '" />
247
- <action type="Rewrite" url="'. $this->wph->default_variables['site_wordpress_relative_path'] .'index.php" />
248
  </rule>
249
  ';
250
 
@@ -263,18 +267,19 @@
263
  return $processing_response;
264
 
265
  $rewrite_base = $this->wph->functions->get_rewrite_base( 'wp-signup.php', FALSE, FALSE );
 
266
 
267
  if($this->wph->server_htaccess_config === TRUE)
268
  {
269
  $text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
270
- $text .= "RewriteRule ^" . $rewrite_base ." ". $this->wph->default_variables['site_wordpress_relative_path'] ."index.php [L]";
271
  }
272
 
273
  if($this->wph->server_web_config === TRUE)
274
  $text = '
275
  <rule name="wph-block_default_wp_signup_php" stopProcessing="true">
276
  <match url="^' . $rewrite_base . '" />
277
- <action type="Rewrite" url="'. $this->wph->default_variables['site_wordpress_relative_path'] .'index.php" />
278
  </rule>
279
  ';
280
 
@@ -292,18 +297,19 @@
292
  return $processing_response;
293
 
294
  $rewrite_base = $this->wph->functions->get_rewrite_base( 'wp-register.php', FALSE, FALSE );
 
295
 
296
  if($this->wph->server_htaccess_config === TRUE)
297
  {
298
  $text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
299
- $text .= "RewriteRule ^" . $rewrite_base ." ". $this->wph->default_variables['site_wordpress_relative_path'] ."index.php?wph-throw-404 [L]";
300
  }
301
 
302
  if($this->wph->server_web_config === TRUE)
303
  $text = '
304
  <rule name="wph-block_default_wp_register_php" stopProcessing="true">
305
  <match url="^'. $rewrite_base .'" />
306
- <action type="Rewrite" url="'. $this->wph->default_variables['site_wordpress_relative_path'] .'index.php?wph-throw-404" />
307
  </rule>
308
  ';
309
 
@@ -321,6 +327,7 @@
321
 
322
  $rewrite_conditional = $this->wph->functions->get_rewrite_base( '', FALSE );
323
  $rewrite_base = $this->wph->functions->get_rewrite_base( '', FALSE);
 
324
 
325
  if($this->wph->server_htaccess_config === TRUE)
326
  {
@@ -334,7 +341,7 @@
334
  $text .= "RewriteCond %{REQUEST_FILENAME} !".$rewrite_conditional."wp-comments-post.php [NC]\n";
335
  $text .= "RewriteCond %{REQUEST_FILENAME} !".$rewrite_conditional."wp-login.php [NC]\n";
336
 
337
- $text .= "RewriteRule ^" . $rewrite_base . "wp-([a-z-])+.php ". $this->wph->default_variables['site_wordpress_relative_path'] ."index.php [L]";
338
  }
339
 
340
  if($this->wph->server_web_config === TRUE)
@@ -350,7 +357,7 @@
350
  <add input="{REQUEST_FILENAME}" pattern="wp-comments-post.php" ignoreCase="true" negate="true" />
351
  <add input="{REQUEST_FILENAME}" pattern="wp-login.php" ignoreCase="true" negate="true" />
352
  </conditions>
353
- <action type="Rewrite" url="'. $this->wph->default_variables['site_wordpress_relative_path'] .'index.php" />
354
  </rule>
355
  ';
356
 
142
  return FALSE;
143
 
144
  $rewrite_base = $this->wph->functions->get_rewrite_base( 'license.txt', FALSE, FALSE );
145
+ $rewrite_to = $this->wph->functions->get_rewrite_to_base( 'index.php', TRUE, FALSE, 'site_path' );
146
 
147
  if($this->wph->server_htaccess_config === TRUE)
148
  {
149
  $text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
150
+ $text .= "RewriteRule ^" . $rewrite_base ." ". $rewrite_to ."?wph-throw-404 [L]";
151
  }
152
 
153
  if($this->wph->server_web_config === TRUE)
154
  $text = '
155
  <rule name="wph-block_license_txt" stopProcessing="true">
156
  <match url="^' . $rewrite_base . '" />
157
+ <action type="Rewrite" url="'. $rewrite_to .'?wph-throw-404" />
158
  </rule>
159
  ';
160
 
173
  return FALSE;
174
 
175
  $rewrite_base = $this->wph->functions->get_rewrite_base( 'readme.html', FALSE, FALSE );
176
+ $rewrite_to = $this->wph->functions->get_rewrite_to_base( 'index.php', TRUE, FALSE, 'site_path' );
177
 
178
  if($this->wph->server_htaccess_config === TRUE)
179
  {
180
  $text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
181
+ $text .= "RewriteRule ^" . $rewrite_base ." ". $rewrite_to ."?wph-throw-404 [L]";
182
  }
183
 
184
  if($this->wph->server_web_config === TRUE)
185
  $text = '
186
  <rule name="wph-block_readme_html" stopProcessing="true">
187
  <match url="^' . $rewrite_base . '" />
188
+ <action type="Rewrite" url="'. $rewrite_to .'?wph-throw-404" />
189
  </rule>
190
  ';
191
 
204
  return FALSE;
205
 
206
  $rewrite_base = $this->wph->functions->get_rewrite_base( 'wp-activate.php', FALSE, FALSE );
207
+ $rewrite_to = $this->wph->functions->get_rewrite_to_base( 'index.php', TRUE, FALSE, 'site_path' );
208
 
209
  if($this->wph->server_htaccess_config === TRUE)
210
  {
211
  $text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
212
+ $text .= "RewriteRule ^" . $rewrite_base ." ". $rewrite_to ."?wph-throw-404 [L]";
213
  }
214
 
215
  if($this->wph->server_web_config === TRUE)
216
  $text = '
217
  <rule name="wph-block_wp_activate_php" stopProcessing="true">
218
  <match url="^' . $rewrite_base . '" />
219
+ <action type="Rewrite" url="'. $rewrite_to .'?wph-throw-404" />
220
  </rule>
221
  ';
222
 
236
  return FALSE;
237
 
238
  $rewrite_base = $this->wph->functions->get_rewrite_base( 'wp-cron.php', FALSE, FALSE );
239
+ $rewrite_to = $this->wph->functions->get_rewrite_to_base( 'index.php', TRUE, FALSE, 'site_path' );
240
 
241
  if($this->wph->server_htaccess_config === TRUE)
242
  {
243
  $text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
244
+ $text .= "RewriteRule ^" . $rewrite_base ." ". $rewrite_to ."?wph-throw-404 [L]";
245
  }
246
 
247
  if($this->wph->server_web_config === TRUE)
248
  $text = '
249
  <rule name="wph-block_wp_cron_php" stopProcessing="true">
250
  <match url="^' . $rewrite_base . '" />
251
+ <action type="Rewrite" url="'. $rewrite_to .'?wph-throw-404" />
252
  </rule>
253
  ';
254
 
267
  return $processing_response;
268
 
269
  $rewrite_base = $this->wph->functions->get_rewrite_base( 'wp-signup.php', FALSE, FALSE );
270
+ $rewrite_to = $this->wph->functions->get_rewrite_to_base( 'index.php', TRUE, FALSE, 'site_path' );
271
 
272
  if($this->wph->server_htaccess_config === TRUE)
273
  {
274
  $text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
275
+ $text .= "RewriteRule ^" . $rewrite_base ." ". $rewrite_to ."?wph-throw-404 [L]";
276
  }
277
 
278
  if($this->wph->server_web_config === TRUE)
279
  $text = '
280
  <rule name="wph-block_default_wp_signup_php" stopProcessing="true">
281
  <match url="^' . $rewrite_base . '" />
282
+ <action type="Rewrite" url="'. $rewrite_to .'?wph-throw-404" />
283
  </rule>
284
  ';
285
 
297
  return $processing_response;
298
 
299
  $rewrite_base = $this->wph->functions->get_rewrite_base( 'wp-register.php', FALSE, FALSE );
300
+ $rewrite_to = $this->wph->functions->get_rewrite_to_base( 'index.php', TRUE, FALSE, 'site_path' );
301
 
302
  if($this->wph->server_htaccess_config === TRUE)
303
  {
304
  $text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
305
+ $text .= "RewriteRule ^" . $rewrite_base ." ". $rewrite_to ."?wph-throw-404 [L]";
306
  }
307
 
308
  if($this->wph->server_web_config === TRUE)
309
  $text = '
310
  <rule name="wph-block_default_wp_register_php" stopProcessing="true">
311
  <match url="^'. $rewrite_base .'" />
312
+ <action type="Rewrite" url="'. $rewrite_to .'?wph-throw-404" />
313
  </rule>
314
  ';
315
 
327
 
328
  $rewrite_conditional = $this->wph->functions->get_rewrite_base( '', FALSE );
329
  $rewrite_base = $this->wph->functions->get_rewrite_base( '', FALSE);
330
+ $rewrite_to = $this->wph->functions->get_rewrite_to_base( 'index.php', TRUE, FALSE, 'site_path' );
331
 
332
  if($this->wph->server_htaccess_config === TRUE)
333
  {
341
  $text .= "RewriteCond %{REQUEST_FILENAME} !".$rewrite_conditional."wp-comments-post.php [NC]\n";
342
  $text .= "RewriteCond %{REQUEST_FILENAME} !".$rewrite_conditional."wp-login.php [NC]\n";
343
 
344
+ $text .= "RewriteRule ^" . $rewrite_base . "wp-([a-z-])+.php ". $rewrite_to ."?wph-throw-404 [L]";
345
  }
346
 
347
  if($this->wph->server_web_config === TRUE)
357
  <add input="{REQUEST_FILENAME}" pattern="wp-comments-post.php" ignoreCase="true" negate="true" />
358
  <add input="{REQUEST_FILENAME}" pattern="wp-login.php" ignoreCase="true" negate="true" />
359
  </conditions>
360
+ <action type="Rewrite" url="'. $rewrite_to .'?wph-throw-404" />
361
  </rule>
362
  ';
363
 
modules/components/rewrite-wp_content_path.php CHANGED
@@ -106,13 +106,14 @@
106
  if (empty( $new_content_path ))
107
  return FALSE;
108
 
109
- $content_directory = ltrim($this->wph->default_variables['content_directory'], '/');
 
110
 
111
  if($this->wph->server_htaccess_config === TRUE)
112
  {
113
  $text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
114
  $text .= "RewriteCond %{HTTP_COOKIE} !^.*wordpress_logged_in.*$ [NC]\n";
115
- $text .= "RewriteRule ^". $content_directory ."(.+) ". $this->wph->default_variables['site_wordpress_relative_path'] ."index.php [L]";
116
 
117
  $processing_response['rewrite'] = $text;
118
  }
@@ -120,11 +121,11 @@
120
  if($this->wph->server_web_config === TRUE)
121
  $processing_response['rewrite'] = '
122
  <rule name="wph-block_wp_content_path" stopProcessing="true">
123
- <match url="^'. $content_directory .'(.+)" />
124
  <conditions>
125
  <add input="{HTTP_COOKIE}" matchType="Pattern" pattern="wordpress_logged_in_[^.]+" negate="true" />
126
  </conditions>
127
- <action type="Rewrite" url="'. $this->wph->default_variables['site_wordpress_relative_path'] .'index.php" />
128
  </rule>
129
  ';
130
 
106
  if (empty( $new_content_path ))
107
  return FALSE;
108
 
109
+ $rewrite_base = $this->wph->functions->get_rewrite_base( $this->wph->default_variables['content_directory'], FALSE, FALSE );
110
+ $rewrite_to = $this->wph->functions->get_rewrite_to_base( 'index.php', TRUE, FALSE, 'site_path' );
111
 
112
  if($this->wph->server_htaccess_config === TRUE)
113
  {
114
  $text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
115
  $text .= "RewriteCond %{HTTP_COOKIE} !^.*wordpress_logged_in.*$ [NC]\n";
116
+ $text .= "RewriteRule ^". $rewrite_base ."(.+) ". $rewrite_to ."?wph-throw-404 [L]";
117
 
118
  $processing_response['rewrite'] = $text;
119
  }
121
  if($this->wph->server_web_config === TRUE)
122
  $processing_response['rewrite'] = '
123
  <rule name="wph-block_wp_content_path" stopProcessing="true">
124
+ <match url="^'. $rewrite_base .'(.+)" />
125
  <conditions>
126
  <add input="{HTTP_COOKIE}" matchType="Pattern" pattern="wordpress_logged_in_[^.]+" negate="true" />
127
  </conditions>
128
+ <action type="Rewrite" url="'. $rewrite_to .'?wph-throw-404" />
129
  </rule>
130
  ';
131
 
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://www.nsp-code.com/donate.php
4
  Tags: wordpress hide, hide, security, improve security, hacking, wp hide, custom login, wp-loging.php, wp-admin, admin hide, login change,
5
  Requires at least: 2.8
6
  Tested up to: 4.8.2
7
- Stable tag: 1.4.6.6
8
  License: GPLv2 or later
9
 
10
  Hide and increase Security for your WordPress website instance using smart techniques. No files are changed on your server.
@@ -249,6 +249,12 @@ Please get in touch with us and we'll do our best to include it for a next versi
249
 
250
  == Changelog ==
251
 
 
 
 
 
 
 
252
  = 1.4.6.6 =
253
  * Fixed rewrite ens slashes for wp-login.php and wp-admin components
254
 
4
  Tags: wordpress hide, hide, security, improve security, hacking, wp hide, custom login, wp-loging.php, wp-admin, admin hide, login change,
5
  Requires at least: 2.8
6
  Tested up to: 4.8.2
7
+ Stable tag: 1.4.7
8
  License: GPLv2 or later
9
 
10
  Hide and increase Security for your WordPress website instance using smart techniques. No files are changed on your server.
249
 
250
  == Changelog ==
251
 
252
+ = 1.4.7 =
253
+ * Rewrite changes for many components
254
+ * Rewrite update for admin and login url
255
+ * Typos fix
256
+ * Compatibility for diferent environments, when WordPress deployed in a domain root, a subdirectory, or it's own folder https://codex.wordpress.org/Giving_WordPress_Its_Own_Directory
257
+
258
  = 1.4.6.6 =
259
  * Fixed rewrite ens slashes for wp-login.php and wp-admin components
260
 
router/class.file-processor.php CHANGED
@@ -26,9 +26,20 @@
26
  $this->load_environment();
27
 
28
  $normalize_abspath = str_replace( '\\', '/', ABSPATH);
 
 
 
 
 
 
 
29
 
30
  //append doc root to path
31
- $this->full_file_path = str_replace( ltrim( $this->environment->site_wordpress_relative_path , '\/'), "", $normalize_abspath) . ltrim($this->file_path, '\/');
 
 
 
 
32
  $this->full_file_path = str_replace( '\\', '/', $this->full_file_path);
33
 
34
  //check if file exists
26
  $this->load_environment();
27
 
28
  $normalize_abspath = str_replace( '\\', '/', ABSPATH);
29
+ $normalize_abspath = str_replace( '\\', '/', $normalize_abspath);
30
+
31
+ //exclude any wordpress directory if exists
32
+ if( $this->environment->wordpress_directory != '' && $this->environment->wordpress_directory != '/')
33
+ {
34
+ $normalize_abspath = substr($normalize_abspath, 0, -1 * strlen( $this->environment->wordpress_directory ));;
35
+ }
36
 
37
  //append doc root to path
38
+ $this->full_file_path = str_replace( ltrim( $this->environment->site_relative_path , '\/'), "", $normalize_abspath);
39
+ $this->full_file_path = str_replace( '\\', '/', $this->full_file_path);
40
+ $this->full_file_path = rtrim( $this->full_file_path , '/') . "/";
41
+
42
+ $this->full_file_path .= ltrim($this->file_path, '\/');
43
  $this->full_file_path = str_replace( '\\', '/', $this->full_file_path);
44
 
45
  //check if file exists
router/environment.php CHANGED
@@ -1,2 +0,0 @@
1
- <?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
2
- $environment_variable = '{"theme":{"folder_name":"twentysixteen","mapped_name":"jd_content\/themes\/theme_name"},"allowed_paths":["F:\/htdocs\/wp-hide-demo\/wp-content\/themes"],"cache_path":"F:\/htdocs\/wp-hide-demo\/wp-content\/cache\/wph\/","site_wordpress_relative_path":"\/","wordpress_directory":"","site_relative_path":""}' ?>
 
 
router/file-process.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
-
3
  /**
4
  * Load WordPress
5
  * Use ShortInit
1
  <?php
2
+
3
  /**
4
  * Load WordPress
5
  * Use ShortInit
wp-hide.php CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://www.nsp-code.com
5
  Description: Hide and increase Security for your WordPress website instance using smart techniques. No files are changed on your server.
6
  Author: Nsp Code
7
  Author URI: http://www.nsp-code.com
8
- Version: 1.4.6.6
9
  Text Domain: wp-hide-security-enhancer
10
  Domain Path: /languages/
11
  */
5
  Description: Hide and increase Security for your WordPress website instance using smart techniques. No files are changed on your server.
6
  Author: Nsp Code
7
  Author URI: http://www.nsp-code.com
8
+ Version: 1.4.7
9
  Text Domain: wp-hide-security-enhancer
10
  Domain Path: /languages/
11
  */