XF 1.5 vbulletin tags.php to Xenforo redirect


Well-known member
I am currently using @xfrocks tags.php
I have tried various 301 redirection rules that are posted around the forums by @Jake Bunce

However, with all solutions I find that this:

is redirected to:

while it should redirect to:

Does anyone have an idea to fix this?


XenForo developer
Staff member
You're going to need a script to do this sort of manipulation.

Without doing any testing, if you put this in the tags.php script before it builds the tag URL, this may help:
$input['tag'] = XenForo_Model::create('XenForo_Model_Tag')->normalizeTag($input['tag']);
$input['tag'] = preg_replace('/[^a-zA-Z0-9_ -]/', '', utf8_romanize(utf8_deaccent($input['tag'])));
$input['tag'] = preg_replace('/[ -]+/', '-', $input['tag']);


XenForo developer
Staff member
With the code I provided, it shouldn't have any spaces left -- the last line replaces them with a "-".

I tested the lines locally and "word1 word2" (which is what your original URL would pass to PHP) turns into "word1-word2".


XenForo developer
Staff member
It should go right before:
$target = XenForo_Link::buildPublicLink('canonical:tags', $input['tag'], $extraParams);
If you're testing after changes, use different URLs in each test. Browsers cache 301s so you need to avoid that. At least add "&x=1" and so on to the original URL to ensure you're running the most recent code.