Redirect PayPal IPN URL - .htaccess

I had my script set up on old.example.com/?paypal_notify=1. There were a few people who signed up to my membership plan while the site was on the old URL. I then moved my site to example.com (no more subdomain) and updated my IPN URL in the PayPal settings.
Unfortunately PayPal is still sending IPNs to the old URL for the members who signed up on the old URL. I tried to redirect the IPN with .htaccess from old.example.com
Redirect /?paypal_notify=1 http://example.com/?paypal_notify=1
This isn't working - I think my redirect rule isn't right. Can someone give me a pointer please? Thanks

Rewrite rules only match the path portion of a URL, which excludes the querystring.
When you want to match based on the querystring, you need to add a RewriteCond directive.
This should do what you want:
RewriteCond %{QUERY_STRING} ^paypal_notify=1$
RewriteRule ^$ http://example.com/?paypal_notify=1 [L,R=302]
When you're happy that it works as needed, replace the R=302 with R=301 to make the redirect permanent.

Related

htaccess to remove the start of a domain

I have a domain that needs to be redirected in order to use a shared SSL certificate. I can redirect the domain no problem, the issue I have is the way this leaves the URL formatting i.e.:
http://www.example.com is redirecting to https://myhost.secure.com/www.example.com
I'm looking to hide the "myhost.secure.com/" part using htaccess but can't find a valid way to do it (I'm a complete novice, sorry). Redirect is being done via htaccess using code below:
RewriteEngine on
RewriteBase /
RewriteCond %{ENV:https} !=on
RewriteRule ^(.*) https://myhost.secure.com/www.example.com/$1 [R,L]
How can I modify this to only display my domain and not the full redirected URL? The redirect works correctly, I see the site as it sits in the secure area of my FTP, but I don't want visitors to see the hosts redirect in the URL.

Redirect to another domain except for home page

I am trying to redirect my old website to a new domain with a few exceptions. These are the current rules that are in my .htaccess file and they are working great:
RewriteEngine on
# handle both specific URL redirects
RewriteRule ^/?product-(?:tag|categories)/([\w-]+) https://www.newdomain.com/parts?category=$1 [R=301,L,NC,QSA]
# redirect everything else
RewriteRule ^(.*)$ https://www.newdoamin.com/$1 [R=301,L,NE]
Now I want to add another rule. I want every page to be redirected to the new domain beside the home page on the old site. With that being said, I still want these exsiting rules to work if it is not the home page.
How can I add another redirect rule to my current htaccess that will not redirect when someone access the home page on the old domain and still apply my current rules?
I was trying to use this answer but I couldn't get my existing rules to work with it.
This should work:
RewriteEngine on
# handle both specific URL redirects
RewriteRule ^/?product-(?:tag|categories)/([\w-]+) https://www.newdomain.com/parts?category=$1 [R=301,L,NC,QSA]
# redirect everything else
RewriteRule ^/?(.+)$ https://www.newdoamin.com/$1 [R=301,L,NE]
.+ matches every URI except the home page. Make sure to clear your browser cache before testing.

301 permanent redirect. (example.com) to (www.example.com) Magento

I expect this to be a simple answer, yet it is a question I have been struggling to confirm after searching on Google and through similar questions.
I am wanting to make sure that my site has a 301 redirect in place to redirect my website URL (example.com) to (www.example.com). When I type in the browser my URL without (www.) in front of it, my page opens as (www.example.com) which is good, however how can I be certain that Google sees this as a redirect for SEO purposes?
I have not added any redirects to my site, so unless my version of Magento (1.7.2) has this redirect already set up or the theme I am using has this redirect set up, then it won't be set up.
I have read that I will have to redirect every page, not just the Home page. I am also aware of the URL Rewrite Management tool in the Magento backend, but I don't know whether I need to add rewrite there or whether I need to enter them into the sitemap.xml or .htaccess file so that Google knows I want my links redirected to the (www.example.com) URL.
Thanks
It will be better direct using htaccess
# Redirect non-www to www:
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
http://dense13.com/blog/2008/02/27/redirecting-non-www-to-www-with-htaccess/
Also,changed in url of secure and unsecure url of magento instance
to
www.example.com ,for please go to admin>system>configuration>General>Web>

How to pass URL Parameters through a .htaccess file

I need to transparently pass a URL parameter through a .htaccess 301 redirection but I am unfamiliar with how to code it.
For example, an Adwords clickthrough appends the following parameter to the landing page url:
&gclid=CKCPq62Sq6wCFY1S4god4FZd1g
Our Google landing page is being redirected like this:
Redirect 301 /old-page /new-page
(We don't want to edit our Google Ads as doing so would lose our existing stats. Thus the redirect..)
How do I preserve the above gclid parameter while redirecting in .htaccess?
Thanks,
Geoff
You can't handle dynamic query strings properly with standard htaccess 301 redirect. In order to do so you should use mod_rewrite:
RewriteEngine On
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule /old-page /new-page?%{QUERY_STRING} [R=301,L]
See, http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html
NOTE: I'm not positive that RewriteCond is required, but it's there to prevent the page from redirecting over and over again. Depending on the rest of the layout of your site, you may need it... although in most cases it's not needed unless you're redirecting all requests.

htaccesss redirect / google webmaster's "change of address"

so I have this in my .htaccess:
Redirect / http://blabla.net/
(which redirects all pages from my old domain, blabla.com, to my new domain - blabla.net)
I also wanted to use "change of address" from the google webmater tools, but it tells me that my old site is not verified (even though it is), and that's because it gets redirected to the new site :)
so how can ignore a single request from .htaccess, like this one:
http://blabla.com/google4befdedcf3629c8a.html
(this should not be redirected to blabla.net/google ...)
?
You can use RewriteCond to check for that specific request.
RewriteCond %{REQUEST_URI} !=/google4befdedcf3629c8a.html
Also, I would encourage you to update your Redirect to respond with a 301 if this is a permanent redirection (the default is 302).
Redirect 301 / http://blabla.net/
UPDATE
RewriteCond uses mod_rewrite, whereas Redirect is mod_alias. So you can't mix and match. I should have explicitly provided the full change if you decide to use RewriteCond. Note that the RewriteEngine does incur overhead. So this may not be the ideal solution.
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !=/google4befdedcf3629c8a.html
RewriteRule ^/(.*) http://blabla.net/$1 [R=301,L]
Just temporarily remove the redirect from htaccess while Google verifies your site, then re-instate the redirect. It should only take about a minute.
Edit: Nevermind, Google will periodically check, and will revoke access if the verification vanishes.

Resources