How to use RewriteRules
-
Hello,
I am combining WordPress and MediaWiki and I have this simple task:
intercepting URLs requests that look like this
https://krcla.org/w-en/index.php?title=Special:UserLogin&returnto=Korean_Resource_Centerand sending them off to this address: https://krcla.org/blog/wp-login.php?&redirect_to=https://krcla.org/en2/Korean_Resource_Center
I looked up a similar project here:
https://wiki.case.edu/CaseWiki:External_Authentication#Intercepting_Calls_to_Special:Userloginand came up with this code on /.htaccess, but obviously it’s not working…
RewriteCond %{REQUEST_URI} ^/w-en/index.php$
RewriteCond %{QUERY_STRING} ^returnto$
RewriteCond %{REQUEST_METHOD} ^GET$
RewriteRule ^(.*)returnto\=(.*)$ ^$1redirect_to=https://krcla.org/en2/$2$ [R,L,N]RewriteCond %{REQUEST_URI} ^/w-en/index.php$
RewriteCond %{QUERY_STRING} ^title=Special:UserLogin
RewriteCond %{REQUEST_METHOD} ^GET$
RewriteRule ^(.*)$ https://krcla.org/blog/wp-login.php [R,L,N]The second ReWriteRule does what it’s supposed to do, which is sending people off to wp-login.php
So with the above htaccess, this link:
https://krcla.org/w-en/index.php?title=Special:UserLogin&returnto=Korean_Resource_Centerbecomes this:
https://krcla.org/blog/wp-login.php?title=Special:UserLogin&returnto=Korean_Resource_CenterBut I still want to replace the string “returnto=” to “redirect_to=https://krcla.org/en2/”
Ideas?
- The topic ‘How to use RewriteRules’ is closed to new replies.