0

I'm currently having a hard time rewriting a URL. The .htaccess file already contains some rules so I need to add a new rule to the existing ones. The current rule includes redirecting to https:// if http:// was used (except if the URL contains 'php05142013'). Here's the current content of the .htaccess file:

ErrorDocument 404 https://mycreditstatus.co.za/404.php
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^mysite\.co\.za$ [NC]
RewriteCond %{REQUEST_URI} !^/(php01202015) [NC]
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^www.mysite\.co\.za$ [NC]
RewriteCond %{REQUEST_URI} !^/(php01202015) [NC]
RewriteRule (.*) https://mycreditstatus.co.za [L,R=301]

What I want to achieve now in addition to the current rules, is to rewrite the URL like https://mysite.co.za/3pv/XnAnr3ABtgo%3D/3irqrHe%2FQJE%3D into https://mysite.co.za/index.php?action=register&auth=1&p=3pv&eid=XnAnr3ABtgo%3D&us=3irqrHe%2FQJE%3D

I've been trying something like ^/([^A-Za-z0-9.)(/\\%-])/([^A-Za-z0-9.)(/\\%-])/([^A-Za-z0-9.)(/\\%-])/([^A-Za-z0-9.)(/\\%-])/?$ index.php?action=register&auth=1&p=$1&eid=$2&us=$3&%{QUERY_STRING} [NC,L] # Process product requests and I'm sure it's wrong. I'm new to mod rewrite and I find it very confusing. Any help would be appreciated. Thanks.

1 Answer 1

1

You can use this new rule:

RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ index.php?action=register&auth=1&p=$1&eid=$2&us=$3 [QSA,L]
Sign up to request clarification or add additional context in comments.

4 Comments

This should be added at the bottom? It does not seem to work.
Thanks. I modified it into RewriteRule ^(.*)([^/]+)/([^/]+)/([^/]+)/?$ index.php?action=register&auth=1&p=$1&eid=$2&us=$3 [QSA,L] and it's now close to the output that I wanted. The URL became mysite.co.za/index.php?action=register&auth=1&p=3pv/… however, it should be &p=3pv&eid=XnAnr3ABtgo%3D=&us=3irqrHe%2FQJE%3D
What is the full URL you entered in browser?
You need to have AllowEncodedSlashes NoDecode in Apache config to pass %2F as is to your htaccess

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.