Forum Moderators: phranque
[edited by: not2easy at 1:21 pm (utc) on May 4, 2020]
[edit reason] Please use example for domains/readability [/edit]
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(forum)\.(example\.co\.uk) [NC]
RewriteRule ^viewtopic\.php$ https://%2/%1/$0 [R=302,L]
RewriteRule ^viewtopic\.php$ https://example.co.uk/forum/$0 [R=302,L]
[edited by: w3dk at 1:51 pm (utc) on May 4, 2020]
https://forum.example.co.uk/viewtopic.php?f=4If the old URL starts with
redirecting to
https://example.co.uk/forum/viewtopic.php?f=4
The new forum uses index.php to link topics/forumsI hope you didn’t mean that “index.php” is part of the visible URL. From the example given, it doesn’t seem to be.
I'm not too sure if the host has mod_rewrite enabledPerhaps you should go find out before asking questions whose answers may prove to be of no use to you. But since you refer to index.php, I think it is wildly improbable that you would not have access to mod_rewrite.
I'm looking for a simple way of redirecting https://forum.example.co.uk/viewtopic.php?f=4 to https://example.co.uk/forum/viewtopic.php?f=4 while not afecting the current link structure of the new forum which uses https://forum.example.co.uk//index.php?threads/example-thread
RewriteRule ^viewtopic\.php$ https://example.co.uk/forum/viewtopic.php [R=301,L]
the document root directory for forum.example.co.ukOuch, good point. The redirects--regardless of what module issues them--have to be located in the directory where the old files lived, or else the requests will never see the redirect.