Reputation: 41
My Google searching seems to be yielding examples for the opposite direction of where I want to go! I'm trying to get requests for site1.org/aff/affusername
to redirect to site2.com/aff/index.php?aff=affusername
, WHILE redirecting site1.org
to site2.com
. What's the best way to do this? I was trying to accomplish the specific redirection to GET with this, but it doesn't redirect anywhere at all:
RewriteRule ^/aff/(.+) http://www.site2.com/index.php\?aff=$1 [L]
Upvotes: 0
Views: 97
Reputation: 10434
If you need to redirect only the aff staff, try to use this:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.site1\.org
RewriteRule ^aff/(.+)$ http://www.site2.com/aff/index.php?aff=$1 [R=permanent,L]
RewriteBase /
RewriteCond %{REQUEST_URI} !^(admin|user)/ # Add here any exclude folders you wish
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^aff/(.+)$ aff/index.php?aff=$1 [QSA,L]
Check this article if you wish to redirect all staff to your index.php: Redirect everything to index.php
Basically the idea is to check if requested file doesn't exists redirect it to index.php
I edited the code above according to your needs.
Upvotes: 1
Reputation: 1059
RewriteEngine On
RewriteRule ^aff/(.*) http://www.site2.com/index.php\?aff=$1 [R=301,L]
Upvotes: 0