Forum Moderators: phranque

Message Too Old, No Replies

Need help with (apache) mod rewrite / redirect

seeking help with 301 redirect

         

Bernard

5:50 pm on Jul 28, 2019 (gmt 0)

10+ Year Member



I'm in the process of migrating one of my vB 3.8 forums to Xenforo. I will be importing all the data into a clean install, so the thread and post IDs will remain the same. I need some help with mod rewrite rule(s) that would cover the following:

Old: www.example.com/forums/f23/thread-title-1255/
New: www.example.com/threads/thread-title.1255/

Old: www.example.com/forums/f23/thread-title-1255/index2.html
New: www.example.com/threads/thread-title.1255/page-2

Old: www.example.com/forums/f23/thread-title-1255/index2.html#post60948
New: www.example.com/threads/thread-title.1255/post-60948


/forums/f#/ should become /threads/ (f# could be f23, f18, etc.)
-threadid should become .threadid

Ideally, index#.html becomes page-# when there is no post id, but if this is too complicated, I can live with simply ignoring index#.html and redirecting to the first page.

#postid should become /post-id

Any help would be greatly appreciated.

lucy24

6:11 pm on Jul 28, 2019 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Most of that seems perfectly straightforward; you just have to put the rules in the right order. What have you tried so far?

Old: www.example.com/forums/f23/thread-title-1255/index2.html#post60948
This one cannot be done in mod_rewrite, or mod_anything-else. The fragment # is used only by the browser; it isn’t part of the request sent to the server. You can redirect to a fragment but you can’t redirect from one.

Bernard

6:35 pm on Jul 28, 2019 (gmt 0)

10+ Year Member



Unfortunately, the pattern matching wizardry of mod rewrite is well beyond me so I haven't tried anything because I have no idea how to do it. I only know enough to know that it should be (mostly) possible.

Does the server still see the #post60948 part of the URL (assuming that it was included in the href/URL that someone clicked to open the page)?

phranque

7:04 pm on Jul 28, 2019 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Does the server still see the #post60948 part of the URL

no - the request sent by the browser includes everything up to but not including the hash mark

lucy24

9:09 pm on Jul 28, 2019 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Is the /f# element simply going away?

Bernard

9:43 pm on Jul 28, 2019 (gmt 0)

10+ Year Member



Yes, the new software doesn't include it in the URL. That said, a member on the Xenforo forums has given me a solution that works through the Admin Control Panel without having to generate any .htaccess rules. Apparently you can configure the software itself to re-interpret URLs. I think I've got this sorted now.