Reputation: 1511
I want to rewrite the url http://127.0.0.1/subscribe/paypal/203/
so that I can get values with php like so
$mode = $_GET['mode'];
$package_id=$_GET['id'];
var_dump($mode);//outputs visa
var_dump($package_id);//outputs 203
and also when the user makes a mistake and types http://127.0.0.1/subscribe/paypal/
it takes them to http://127.0.0.1/subscribe.php
My .htaccess file's contents are as shown below.
RewriteEngine on
RewriteRule ^subscribe/.*/([A-Za-z0-9-]+)/?$ subscribe.php?mode=$1&id=$2 [NC,L]
Upvotes: 2
Views: 50
Reputation: 41219
Try this in your /.htaccess
file
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_URI} ^/subscribe/paypal/?$
RewriteRule ^subscribe/(.*)/?$ /subscribe.php?mode=$1 [QSA,NC,L]
RewriteRule ^subscribe/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/?$ /subscribe.php?mode=$1&id=$2 [QSA,NC,L]
Upvotes: 1