jimuty
jimuty

Reputation: 29

Make exception in mode_rewrite rules

I have a script that use payment API and after successful payment send user to a link and script verify the payment.

But I started to use a mod_rewrite to make urls friendly. After editing .htaccess many of users email me and say that their payment is nod added to their account.

I am using this rules.

# Redirect "ugly" URLs to the desired URLs
RewriteCond %{THE_REQUEST} \?a=([^\ ]*)
RewriteRule ^$ /%1? [R=301,L]

# Internally rewrite the "pretty" URL to the real URL
RewriteCond %{QUERY_STRING} ^$
RewriteCond %{THE_REQUEST} !/admin.php [NC]
RewriteRule ^([^/]*)$ /?a=$1 [L]

It basicaly rewrite hort.com/?a=page to hort.com/page

Payments accept link is

 hort.com/index.php?a=return_visa&process=yes

and also this one

 hort.com/?a=return_visa&process=yes

I want something to add to my rules to stop edithing this links.

Upvotes: 1

Views: 44

Answers (2)

anubhava
anubhava

Reputation: 784898

Try these rules:

# Redirect "ugly" URLs to the desired URLs
RewriteCond %{THE_REQUEST} \?a=([^&\s]+)\s
RewriteRule ^(index\.php)?$ /%1? [R=301,L]

# Internally rewrite the "pretty" URL to the real URL
RewriteCond %{QUERY_STRING} ^$
RewriteCond %{THE_REQUEST} !/admin\.php [NC]
RewriteRule ^([^/.]+)/?$ ?a=$1 [L,QSA]

Upvotes: 1

Croises
Croises

Reputation: 18671

You can change the first redirect:

# Redirect "ugly" URLs to the desired URLs
RewriteCond %{THE_REQUEST} \?a=([^\ ]*)
RewriteCond %{THE_REQUEST} !\?a=return_visa [NC]
RewriteRule ^$ /%1? [R=301,L]

Upvotes: 0

Related Questions