I'm having issues trying to implement a redirect for my phpBB forum. Basically the forum used to be on the root and now it's inside a /foro/ folder.
I already have in place some rules for my Wordpress blog that work perfectly:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
The thing is that if the user used to go to:
http://www.coliseoweb.com/viewtopic.php?f=10&t=3567
I want them now to go to:
http://www.coliseoweb.com/foro/viewtopic.php?f=10&t=3567
Keeping all the same variables. I've tried adding this:
RewriteRule ^/viewforum.php(.*) /foro/viewforum.php$1 [R=301,L]
And also this:
RedirectMatch 301 ^/viewtopic.php(.*)$ http://www.coliseoweb.com/foro/viewtopic.php$1
But I have no luck.
Maybe they are correct but I'm adding them in the wrong place? Maybe I need something else?
Help would be great!
Thanks!
Javier
Ah sorry! Your regex doesn't need the leading slash. Try:
RewriteRule ^viewforum.php(.*) /foro/viewforum.php$1 [R=301,L]
You should better replace the code RewriteRule . /index.php [L]
RewriteRule . /index.php [L]
on your code with RewriteRule ^viewforum.php([^/]*) /foro/viewforum.php$1 [R=301,L]
Now, if you need to have both working... Then you could try this:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^viewforum.php([^/]*) /foro/viewforum.php$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.