jimuty jimuty - 16 days ago 6
Apache Configuration Question

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.

Answer

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]