Mod rewrite problem- help in changing to new URL

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

https://xxx.org/forum/topic/144934-pio-threatened-rti-applicant/

is now

https://xxx.org/forum**s**/topic/144934-pio-threatened-rti-applicant/

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

Try something like:-

RewriteEngine On
RewriteRule ^forum/(.*)$ /forums/$1 [NC,L]

This isn’t my area of expertise, but isn’t this all you need to redirect a directory?

Redirect permanent /forum/ https://xxx.org/forums/

Well It doesn’t redirect the URLs . It just write forum to forums
But I have 500000 URL after forum/abc.html forum/bcc.html which need redirection

I had tried that but it creates a redirect loop. All server guys have failed to resolve this.

Is there other stuff in the htacces which is interfering with this?

I have this

Options -MultiViews RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteRule \.(js|css|jpeg|jpg|gif|png|ico|map)(\?|$) /404error.php [L,NC] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [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

But that will need 500,000 lines of redirects, not practical. Using the wildcard should do the same with just one line.

Would you be able to suggest how to go about it

The line I posted should work. Though should maybe have a 301 flag, if a permanent redirect is what you intend on.

RewriteRule ^forum/(.*)$ /forums/$1 [R=301,L]

I tried that, it doesn’t work

Indeed that should work. And it should be the first line after RewriteEngine On

Options -MultiViews
RewriteEngine On
RewriteRule ^forum/(.*)$ /forums/$1 [R=301,L]
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .(js|css|jpeg|jpg|gif|png|ico|map)(\?|$) /404error.php [L,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

Thanks for the support.
I did exactly that. Please visit rtiindia.org/forum to see

If you visit the root of the forum folder: rtiindia.org/forum it needs the trailing slash after forum to work with my redirect. But other than that, it appears work.

Yes, that seems to be working. Thank you for the support. There are many more such wild card redirect, I need to ask. But that is for later.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.