XF 1.5 vbulletin tags.php to Xenforo redirect

Alpha1

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:
/forum/tags.php?tag=word1+word2

is redirected to:
/tags/word1+word2/

while it should redirect to:
/tags/word1-word2/

Does anyone have an idea to fix this?
 
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:
Code:
$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']);
 
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".
 
It should go right before:
Code:
$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.
 
Top Bottom