Post by Joe1234 » Tue Nov 29, 2022 10:01 am

I'm trying to do a partial rewrite of my url, NOT redirect. Nothing I try is working. I want to change the word "coupon=" and the alphanumeric values that come after.

So the url is "https://website.com/index.php?coupon=fjio3a"
I want it to be "https://website.com/shop

Among 50 other things my final try was

Code: Select all

RewriteEngine On
RewriteCond   %{QUERY_STRING}    ^coupon=([0-9]+)$
RewriteRule   ^index.php$     ^shop$     [L]
I know the coupon code I have this searching for is numeric, that's because my tests have been with numeric sequence and I couldn't find the alphanumeric code. Any help? Thanks.
Last edited by Joe1234 on Thu Dec 01, 2022 1:28 pm, edited 1 time in total.

v3.0.3.9 php 8.1
I'm here for a reason, if your response is contact a/the developer, just don't reply.


Active Member

Posts

Joined
Sat Jan 01, 2022 5:47 am

Post by ADD Creative » Tue Nov 29, 2022 6:40 pm

Try.

Code: Select all

RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} ^coupon=[0-9a-zA-Z]+$
RewriteRule ^index\.php$ shop? [L]
Are you sure you want a rewrite and not a redirect?

www.add-creative.co.uk


Expert Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by Joe1234 » Tue Nov 29, 2022 10:00 pm

Thanks, but that code leads to a page not found oc error and the original url still shows.

I don't know/think a redirect would work for me. My thinking and understanding...I may be wrong...with the rewrite the essence of what the url is is still there, just masked by the server, so OC will pick up the coupon from the original url, but the user wont see it in their browser. Whereas if I did a redirect, then the coupon would not be there any longer for OC to pickup.

v3.0.3.9 php 8.1
I'm here for a reason, if your response is contact a/the developer, just don't reply.


Active Member

Posts

Joined
Sat Jan 01, 2022 5:47 am

Post by Joe1234 » Wed Nov 30, 2022 4:21 am

Disregard, although I'd like to know why this isn't working for me or what I'm doing incorrectly, I decided to do a php encryption/decryption of the coupon code and that seems to be working so far.

v3.0.3.9 php 8.1
I'm here for a reason, if your response is contact a/the developer, just don't reply.


Active Member

Posts

Joined
Sat Jan 01, 2022 5:47 am

Post by straightlight » Wed Nov 30, 2022 4:26 am

Joe1234 wrote:
Wed Nov 30, 2022 4:21 am
Disregard, although I'd like to know why this isn't working for me or what I'm doing incorrectly, I decided to do a php encryption/decryption of the coupon code and that seems to be working so far.
You could try with the token helper function to accomplish this. However, since this issue has been resolved, please add: [SOLVED] at the beginning of the subject line on your first post.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by Joe1234 » Wed Nov 30, 2022 3:15 pm

Odd issue, I'll break it down to the final point.
In "catalog\controller\startup\startup.php" this added piece of code "$this->session->data['coupon'] = " doesn't seem to process any coupon with a letter in it, only numeric coupons. No errors or anything pops up. I've tried 6 different coupon codes, and it only accepts coupons with numerals alone. This has nothing to do with the encryption because I'm putting the coupon right there on the "=". Any thoughts?

v3.0.3.9 php 8.1
I'm here for a reason, if your response is contact a/the developer, just don't reply.


Active Member

Posts

Joined
Sat Jan 01, 2022 5:47 am

Post by ADD Creative » Wed Nov 30, 2022 7:09 pm

What the rewrite you had does is. The user will always see /index.php?coupon=fjio3a in their browser but the actual server will rewrite the request to be /shop so if you don't have a shop directory with an index file in you will get a 404.

It sounds like you want the user to see /shop in the browser, but be rewritten on the server to /index.php?coupon=fjio3a. That would require a totally different set of rules.

Code: Select all

RewriteEngine On
RewriteBase /
RewriteRule ^shop$ index.php?coupon=fjio3a [L,QSA]
With your other issue. What are you setting "$this->session->data['coupon']" to and how are you actually testing it.

www.add-creative.co.uk


Expert Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by Joe1234 » Thu Dec 01, 2022 1:26 pm

Found the issue. Seems I happened to have all the coupons with letters set to Customer Login. Thanks.

v3.0.3.9 php 8.1
I'm here for a reason, if your response is contact a/the developer, just don't reply.


Active Member

Posts

Joined
Sat Jan 01, 2022 5:47 am
Who is online

Users browsing this forum: No registered users and 105 guests