Hi coelmay,
The Shortn.It plugin isn’t designed to intercept all requests made on the short domain, but instead to intercept the /path. You’ll notice that the plugin redirects example.com/short the same as exm.pl/short.
If you want, you can create an Apache rewrite so the short domain will always redirect all requests to the same location on the full domain. The short URLs will still work as expected as well as normal page/post links all ending up on the full domain.
Hope that makes sense and helps,
docofmedia
Yeah, makes sense.
In shortn_it_get_matching_post_id I’ve added:
`if ( preg_match(‘/^(index\.php)?\?p\=(.*)$/’, $the_short) ) {
return substr($the_short, strpos($the_short, ‘?p=’)+3,strlen($the_short));
}`
after if( $the_short == '' ).
In shortn_it_headers after the if I’ve added:
`else {
global $wpdb;
$page_slug = trim($_SERVER[‘REQUEST_URI’], ‘/’);
if ( ($wpdb->get_var( ‘SELECT ID FROM ' . $wpdb->posts .' WHERE post_name = “‘.$page_slug.'”‘)) !== FALSE ) {
$permalink = home_url(‘/’) . $page_slug . ‘/’;
if ( $permalink != $current_url ) {
wp_redirect( $permalink );
exit();
}
}
}`
May not be the prettiest code in the world, but it works for me.
And into .htacces I’ve added
`RewriteCond %{HTTP_HOST} ^exm\.pl$
RewriteCond %{REQUEST_URI} ^/?$
RewriteRule ^(.*)$ http://example.com/$1 [R,L]`
to capture people browsing directly to exm.pl.
Modified that to
if ( $page_slug != '' && ($wpdb->get_var( 'SELECT ID FROM‘ . $wpdb->posts .’WHEREpost_name= "'.$page_slug.'"')) !== FALSE )
And I’ve now removed the else as is breaks pretty much everything.