Rewrite rules for short urls
-
I am using a url shortner plugin named ‘Hum’. The plugin generates short urls as domain.com/<single letter>/<anything>. e.g., domain.com/p/xyz.
I want to change the plugin so that I can replace <single letter> with longer words. However, this change creates a problem in url redirection.
The plugin defines the rewrite rules aspublic function rewrite_rules( $wp_rewrite ) {
$hum_rules = array(
‘([a-z](/.*)?$)’ => ‘index.php?hum=$matches[1]’,
);
$wp_rewrite->rules = $hum_rules + $wp_rewrite->rules;
}I tried to change [a-z] to allow for instance ‘video’ but my problem is when I define the rules to allow domain.com/video/xyz, the rewrite rules start conflicting with my post urls which are domain.com/video/<post-slug>. If I try to define short url as domain.com/vid/xvy and update the rules in the above function accordingly then it just works fine.
I am using custom structure for permalinks as /%category%/%postname% and my .htaccess is
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule># END WordPress
Anyone has the idea how can I solve this?
- The topic ‘Rewrite rules for short urls’ is closed to new replies.