rewrite /forum to /forums (but extensive URLS)

shrawaaan

New member
Joined
Jun 3, 2018
Messages
1
Points
0
I had a forum with /forum but it has changed to /forums I want to know if there is a single line code which can redirect my old URL to new ones. It is not simple redirection from /forum to /forums The URL after /forum/abc.html are now /forums/abc.html There are some 500000 URL that need to be changed. Could anybody help

For example

xxx.org/forum/topic/144934-pio-threatened-rti-applicant/ is now xxx.org/forums/topic/144934-pio-threatened-rti-applicant/

If you see above the change is just 'S' for all the 500000 URLs

I have already tried this RewriteEngine On RewriteRule ^forum/(.*)$ /forums/$1 [NC,L]
I am left with permanant redirection ony I am trying this way Redirect 301 /forum/42534-how-know-my-pf-account-no.html /forums/42534-how-know-my-pf-account-no.html

PLease let me know if you can help
Thanks
Shrawan
 

Rob Whisonant

Moderator
Joined
May 24, 2016
Messages
2,481
Points
113
Not sure if I understand what you are really after. But if all you are trying to do is change what you tried to a 301, the below would work.

RewriteRule ^subdirectory/(.*)$ /anotherdirectory/$1 [R=301,NC,L]
 

dineshsma

New member
Joined
Jun 11, 2018
Messages
6
Points
0
If your website has high number of visitors then rewriting 500000 URLs will overload your webserver. Use below command to replace all the links in all the files. Make sure to backup the forum just in case if anything goes wrong.

Code:
for i in `grep -lr "xxx.org/forum/"`; do sed -i 's/xxx\.org\/forum\//xxx\.org\/forums\//g' $i; done
To replace the links from database, dump the database in sql format (for ex. database.sql) then run below command replace the link
Code:
sed -i 's/xxx\.org\/forum\//xxx\.org\/forums\//g' database.sql
After successful execution of the above command, restore the database.
 
Older threads
Replies
3
Views
1,532
Replies
1
Views
5,672
Latest threads
Replies
2
Views
101
Replies
9
Views
175
Replies
2
Views
93
Recommended threads
Replies
7
Views
4,617
Replies
3
Views
5,177
Replies
1
Views
2,010
Replies
6
Views
3,475
Similar threads
Replies
2
Views
2,646
Replies
3
Views
8,267

Latest postsNew threads

Referral contests

Referral link for :

Sponsors

Popular tags

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top