I have mediawiki installed inside mydomain.com/wiki/ folder and I also have phpbb installed in the root like mydomain.com. I already have user profile pages in my phpbb installation and the urls to those pages are like: mydomain.com/memberlist.php?mode=viewprofile&un=XYZ
What I want to do is, I dont want to use the Mediawiki's user pages and user talk pages. Instead I want to redirect all user pages to the phpbb's user profile page that is in the root directory. I tried to redirect using the htaccess method but couldnt get it to work. My htaccess inside the root folder has the following rewrite rule:
redirect 301 wiki/index.php/User:* http://www.mydomain.com/memberlist.php?mode=viewprofile&un=*
I need help with these:
1) Can someone have a look at the above code and let me know if I've got something wrong or if this cannot be done?
2) I have * next to the 'User:' since I want to transfer all existing Mediawiki User Pages to phpbb's memberlist.php page. Is that correct?
3) Also I noticed that in Mediawiki, the userpages have different types of URL. For example, sometimes its like: wiki/index.php/User:XYZ (or) wiki/index.php?title=User:XYZ (or) wiki/index.php?title=User:XYZ&action=edit&redlink=1, etc... So in that case, do I need to add different htaccess redirect rule for each type of urls's?
4) Is there another method like adding a redirect rule in LocalSettings.php or something else?
5) What is the right method for doing this?
I am stumped!
Can someone have a look at the above code and let me know if I've got something wrong or if this cannot be done?
Yes, your Redirect
directive is wrong. It isn't a regular expression and thus you can't have stuff like *
in it, unless you're actually trying to match against a "*".
You're probably not going to be able to do the redirect from the htaccess file in your root directory as Mediawiki uses its own htaccess. So in the htaccess file that's in the /wiki/
folder, try adding this above any rewrite rules that are already there:
RewriteCond %{QUERY_STRING} ^title=User:([^&]+) [NC]
RewriteRule ^ /memberlist.php?mode=viewprofile&un=%1 [L,R=301]
That should take care of the URLs that look like: /index.php?title=User:XYZ
RewriteRule User:(.*)$ /memberlist.php?mode=viewprofile&un=$1 [L,R=301]
And that should take care of the URLs that look like: /User:XYZ
Is there another method like adding a redirect rule in LocalSettings.php or something else?
I don't know of anything you can set in the LocalSettings.php
to do this kind of redirect, but I really wouldn't be surprised if there was some Mediawiki specific solution to this problem, maybe some add-on code that automatically redirects pages in a certain namespace.