add exceptions to plugin

Status
Not open for further replies.

ninoblack

Active Member
103
2011
12
0
I use a plugin that redirects all urls in high to version lowercased box. He is very good and helps me avoid duplicate content in Wordpress.


However, there is a list of 800 urls that should be added as an exception to the plugin.


It should not redirect these 800 pages to version lowercased.


Anyone have a solution?

I think this is very simple and anyone with intimacy with php you can help me, but if it is not so simple, I can pay for it.


The Code:

PHP:
if(!is_admin()){  add_action( 'init', 'storm_force_lowercase' );}
function storm_force_lowercase(){
  $url = $_SERVER['REQUEST_URI'];
  if(preg_match('/[\.]/', $url)){    return;  }
  if(preg_match('/[A-Z]/', $url)){
    $lc_url = strtolower($url);    header('HTTP/1.1 301 Moved Permanently');      header("Location: " . $lc_url);    exit(0);  }
}

Thanks for all
 
1 comment
I use a plugin that redirects all urls in high to version lowercased box. He is very good and helps me avoid duplicate content in Wordpress.


However, there is a list of 800 urls that should be added as an exception to the plugin.


It should not redirect these 800 pages to version lowercased.


Anyone have a solution?

I think this is very simple and anyone with intimacy with php you can help me, but if it is not so simple, I can pay for it.


The Code:

PHP:
if(!is_admin()){  add_action( 'init', 'storm_force_lowercase' );}
function storm_force_lowercase(){
  $url = $_SERVER['REQUEST_URI'];
  if(preg_match('/[\.]/', $url)){    return;  }
  if(preg_match('/[A-Z]/', $url)){
    $lc_url = strtolower($url);    header('HTTP/1.1 301 Moved Permanently');      header("Location: " . $lc_url);    exit(0);  }
}

Thanks for all

It should look something like this, I haven't tested it though, but it should do the trick:

(you will have to put into the array all the exception pages)

PHP:
$exception = array(
"PAGE1.html",
"PAGE2.html",
"PAGE3.html",
"PAGE4.html",
"etc...");

if(!is_admin()){  add_action( 'init', 'storm_force_lowercase' );}
function storm_force_lowercase(){
  $url = $_SERVER['REQUEST_URI'];
  if (!in_array($url, $exception))
  {
  	if(preg_match('/[\.]/', $url)){    return;  }
  	if(preg_match('/[A-Z]/', $url)){
    	$lc_url = strtolower($url);    header('HTTP/1.1 301 Moved Permanently');      header("Location: " . $lc_url);    exit(0);  }
  }
}
 
Last edited:
Status
Not open for further replies.
Back
Top