How to rewrite /?custom_ref= with /?ref= using htaccess rewrite - .htaccess

How to rewrite
/?custom_ref=
with
/?ref=
using htaccess rewrite???

RewriteEngine On
RewriteCond %{QUERY_STRING} custom_ref=(.*)
RewriteRule (.*) /?ref=%1 [R=301,L]
Can you please tell me the directory/file that you using this query on so I make sure this code will only work with it.

Related

Redirect url with get variables use .htaccess

It is possible to redirect in .htaccess
this url
http://test.com/uploads/image.jpg?w=200
to this
http://test.com/public/uploads/image/200.jpg
?
I need this to cache system in my rest API.
I'm not sure that is possible rewrite get variable in this way.
Cheers
Check this rule, maybe it help.
RewriteEngine On
RewriteCond %{REQUEST_URI} ^uploads/image.jpg
RewriteCond %{QUERY_STRING} w=(.*)
RewriteRule ^(.*)$ /public/uploads/image/%1.jpg? [R=301,L]

Rewrite part of URL with htaccess

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]

change the url using with htaccess

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.

How to mod-rewrite subdomain directory using htaccess

I have something like this.
http://www.mydomain.com/page.php?s=database&name=page
How do i mod rewrite it in such a way that it become.
http://www.database.mydomain.com/page/
I successfully map it into a subdomain format as below using (database.mydomain.com)
RewriteCond %{HTTP_HOST} ([^.]+)\.localhost
RewriteRule ^(.*)$ s/index.php?s=%1
Have no idea how to proceed further. This is what i have :
RewriteCond %{HTTP_HOST} ([^.]+)\.localhost\([^.]+)\
RewriteRule ^(.*)$ s/page.php?name=%1&s=%2
Appreciate any expert help. :)
You don't need to rewrite subdomains
Rewrite only request uri and be fine.

htaccess rewrite if no rewrite was provided

First off I'm not an expert in htaccess stuff, but i try to accomplish the following for some SEO fixes.
When the url is loaded, without any params/rewrite it should get some data attached before it continues.
For example:
http://www.domain.com >>> http://www.domain.com/en/
I thought the rewrite was right like this, but didn't work (500)
RewriteCond %{REQUEST_URI} !^(en|nl|de|etc)$
RewriteRule ^(.*)$ /en/ [L,R=301]
added
RewriteRule ^(/?[^/]+) /index.php?rewrite=1 [L] # tell php we got a rewrite
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)$ $1/en/ [NC]

Resources