Basically, you should use this htaccess rule:
RewriteRule ^categoryname/page/([0-9]+)$ /categoryname/$1 [L,R=301] RewriteRule ^categoryname/([0-9]+)$ /categoryname/page/$1 [L]
- The first rule will change your old
categoryname/page/3 URL to categoryname/3 . - The second rule is an invisible redirect from
categoryname/3 to categoryname/page/3 .
Then you can use both categoryname/page/3 and categoryname/3 in your code, this will always show a short version in the url.
Please note that you may experience problems with another similar URL (make sure you will never categoryname/3 elsewhere)
EDIT
Inifinite loop ... how could I miss it!
To avoid this loop, you need to find the "final url" for category/page/3 (for example: index.php?category_name=categoryname&page=3 ) and use it in the second rule:
RewriteRule ^categoryname/page/([0-9]+)$ /categoryname/$1 [L,R=301] RewriteRule ^categoryname/([0-9]+)$ /index.php?category_name=categoryname&page=$1 [L]
source share