I've been trying to make a htaccess rewrite for this URL:
https://www.test.com/wp-login.php?action=rp&key=abcd12345&login=username
to
https://www.test.com/reset-password/?action=rp&key=abcd12345&login=username
RewriteEngine on
RewriteRule ^reset-password/?rp=([a-z]+)&key=([a-zA-Z0-9]+)&login=([a-zA-Z0-9_-]+)$ wp-login.php?action=$1&key=$2&login=$3 [L,R=302]
It doesn't work, can anyone shed some light?
Thanks.
QueryString is not part of match in rule's pattern, you need to match against %{QUERY_STRING} .
RewriteEngine on
RewriteCond %{QUERY_STRING} ^rp=([a-z]+)&key=([a-zA-Z0-9]+)&login=([a-zA-Z0-9_-]+)$
RewriteRule ^reset-password/ wp-login.php?action=%1&key=%2&login=%3 [L,R=302]
Related
I need to be able to rewrite http://example.com/staging/details/?postid=23 so that it becomes http://example.com/staging/grandhotelterduin
I am not sure how the .htaccess rule should be?
I have came up with something like this
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^grandhotelterduin/(.*)$ ./details/?postid=23 [L,NC]
I am not sure I am doing this correctly, can you plz help
I want it such that the http://example.com/staging/grandhotelterduin/ get redirected to http://example.com/staging/details/?postid=23 but the url that appears in the browser is `http://example.com/staging/grandhotelterduin
Use this:
RewriteEngine On
RewriteRule ^grandhotelterduin$ /staging/details/?postid=23 [L]
It will give you the following URL:
http://sheetz.nl/grandhotelterduin
EDIT:
RewriteCond %{THE_REQUEST} /staging/details/?postid=([0-9]+) [NC]
RewriteRule ^ /staging/grandhotelterduin [L,R]
I'm trying to rewrite part of a URL with a 301 htaccess rewrite.
So far I got this
RewriteRule ^index.php?option=com_payplans&view=subscription&task=display&subscription_key=(.*)$ /subscriptiondetails/display/$1 [R=301,L,NC]
I want to go from
http://www.example.com/index.php?option=com_payplans&view=subscription&task=display&subscription_key=8O56WXCMQEZ5
to
http://www.example.com/subscriptiondetails/display/8O56WXCMQEZ5
Just can't quite figure out what I'm missing or doing wrong.
You need to use a RewriteCond to match query string:
RewriteCond %{QUERY_STRING} ^option=com_payplans&view=subscription&task=display&subscription_key=(.*)$
RewriteRule ^index\.php$ /subscriptiondetails/display/%1? [R=301,L,NC]
I use following code:
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{QUERY_STRING} (^|&)post_type=product(&|$)
RewriteCond %{QUERY_STRING} !(^|&)product_cat=xyz
RewriteRule ^(.*)$ http://www.example.com/?%{QUERY_STRING}&product_cat=xyz
but it doesn't works.
I need to add variable "product_cat=xyz" where query_string contains "post_type=product" and it doesn't just contains "product_cat=xyz".
Examples:
If url is "http://www.example.com/?post_type=product&product_cat=xyz" then htacces leaves it unchanged.
If url is "http://www.example.com/?post_type=product" then htacces must add "&product_cat=xyz"
:-) Can you help me, please?
Thanks in advance.
You can use:
RewriteEngine on
RewriteCond %{QUERY_STRING} (^|&)post_type=product(&|$)
RewriteCond %{QUERY_STRING} !(^|&)product_cat=xyz(&|$)
RewriteRule ^ http://www.example.com/?product_cat=xyz [QSA,L]
i am trying to change the url using htaccess rewrite
i want to change this url
page/details.php?name=abcdef&id=18
to
page/abcdef
Here my sample code for this
RewriteEngine On
RewriteRule ^company/([A-Za-z0-9-]+)/$1 company/details.php?name=$1&id=$2 [R=301,L]
this is not working, and also i was tried many code but not working,please help me to find htaccess code for this url
Thanks advance
This should do what you're after:
RewriteCond %{QUERY_STRING} ^.*name=([a-zA-Z0-9]*).*$
RewriteRule ^page/(.*)$ page/%1? [R=301,L]
Try this one:
RewriteEngine on
RewriteCond %{QUERY_STRING} ^name=(.*)&id=(.*)$
RewriteRule ^page/(.*)$ /page/%1? [R=301,L]
This will check for these 2 parameters in the query string.
Is it possible to redirect based on an url that would be as:
www.url.com/stuff.php
But not redirect if the url contained any characters after the php, as such:
www.url.com/stuff.php?variables=values&othervariable=othervalue&etc=more
I have no clue how to wriite this either.
Thanks in advance!
Edit: basically I need the redirect to happen to www.url2.com only if www.url.com ends with .php, but not if the .php is followed by variables.
try
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^/site.com/?$ /site.com/cart.php [R=301,NC,L]
Try:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^/?cart.php$ / [L,R=301]
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^stuff.php$ RELATIVE_OR_ABSOLUTE_URL_HERE [L]