PDA

View Full Version : VB4 .htaccess redirect old url to new url


decentplayboy
10-08-2017, 11:43 AM
Hi, i just changed my forum domain. I want to redirect all my existing google search result from old url to my new url

for example

i want to redirect the exact link as below

http://oldurl.com --> http://newurl.com

http://oldurl.com/forum --> http://newurl.com/forum

http://oldurl.com/forum/forumdisplay.php?f=275 --> http://newurl.com/forum/forumdisplay.php?f=275 (f=275 is for example)

http://oldurl.com/forum/showthread.php?t=7462 --> http://newurl.com/forum/showthread.php?t=7462 (t=7462 is for example)

http://oldurl.com/forum/showthread.php?t=9936&p=972978&viewfull=1#post972978 --> http://newurl.com/forum/showthread.php?t=9936&p=972978&viewfull=1#post972978

what is the .htaccess rewrite rule that serve this purpose? which .htaccess should i modify? public_html or /forum

your help is much appreciated. thanks

Brandon Sheley
10-08-2017, 01:33 PM
You'll need several lines in your htaccess to cover everything.
See if you can catch joe (@BirdOPrey5 (https://vborg.vbsupport.ru/member.php?u=258922)) and ask him. He's helped me out before with regex code to handle redirecting all threads in a section.

You're htaccess would go in the root of your old url, or by your examples it could go in your forum folder put I would go root placement.

decentplayboy
10-08-2017, 01:45 PM
You'll need several lines in your htaccess to cover everything.
See if you can catch joe (@BirdOPrey5 (https://vborg.vbsupport.ru/member.php?u=258922)) and ask him. He's helped me out before with regex code to handle redirecting all threads in a section.

You're htaccess would go in the root of your old url, or by your examples it could go in your forum folder put I would go root placement.

thanks alot brandon...i will pm bro birdOPrey5

Dave
10-08-2017, 09:35 PM
You could take a look at http://www.inmotionhosting.com/support/website/redirects/setting-up-a-301-permanent-redirect-via-htaccess which is almost exactly what you want.

As for your question that you PMed me (regarding fixing URL's in private messages), you can use the following query (add the table prefix if you use any):

UPDATE pmtext SET message = REPLACE(message, 'olddomain.com', 'newdomain.com') WHERE message like '%olddomain.com%';

BirdOPrey5
10-11-2017, 10:52 AM
If you're keeping the same URL structure on both domains then on the old domain, in the public_html folder, create an .htaccess file with this content:


RewriteEngine on
RewriteRule ^(.*)$ http://www.newsite.com$1 [R=301,L]


Where you replace http://www.newsite.com with the base URL to your new domain.

webmastersun
10-19-2017, 12:52 PM
Hi, i just changed my forum domain. I want to redirect all my existing google search result from old url to my new url

for example

i want to redirect the exact link as below

http://oldurl.com --> http://newurl.com

http://oldurl.com/forum --> http://newurl.com/forum

http://oldurl.com/forum/forumdisplay.php?f=275 --> http://newurl.com/forum/forumdisplay.php?f=275 (f=275 is for example)

http://oldurl.com/forum/showthread.php?t=7462 --> http://newurl.com/forum/showthread.php?t=7462 (t=7462 is for example)

http://oldurl.com/forum/showthread.php?t=9936&p=972978&viewfull=1#post972978 --> http://newurl.com/forum/showthread.php?t=9936&p=972978&viewfull=1#post972978

what is the .htaccess rewrite rule that serve this purpose? which .htaccess should i modify? public_html or /forum

your help is much appreciated. thanks

Using these .htaccess codes in this post https://forumweb.hosting/13528-how-to-redirect-a-domain-without-changing-the-url.html can help you out.

Hope it helps!