Hi all I need help with redirect in htaccess
My problem: how to get param3 value and redirect there in htaccess
From
https://exampletracking.com/track/?param1=value1¶m2=value2¶m3=https://example2.com/product/
to
https://example2.com/product/
I need help with redirect in htaccess, Because for Google Adwords need go redirection from tracking template to a product page server side. I don't have any experience with htaccess so can't really show any example for htaccess.
First I redirect client side with .JS code below successfully but google don't accepted because is client side redirect
var tracUrl = window.location.pathname;
var urlPath = document.location.protocol + "//" + document.location.hostname + "/" + document.location.search
var urlArray = urlPath.split("param3=")[1].substring(0, 1000);
location.replace(urlArray);
Im kinda stuck so for any help I will be grateful.
This work for me. Maybe will someone find also useful
<IfModule mod_rewrite.c>
RewriteEngine On
# Redirect Query String (Apache 2.4)
RewriteCond %{QUERY_STRING} param3=https://example2.com/([^/]+) [NC]
RewriteRule (.*) /%1 [R=301,L,QSD]
</IfModule>
Related
I'm new to htaccess so please bear with me..
I'm trying to redirect traffic to URLs with query string to the root of my site as these URLs are no longer used.
Here is an example:
I would like traffic to this URL
https://www.DomainName.com/subdir1/subdir2/cond_e.asp?obark=110246
to go to http://www.DomainName.com
I do not need to keep the URL or anything just redirect to my homepage.
I need to do this for query string value from obark=110246 all the way up to obark=120000.
I've basically played around with the below to get at least one URL to redirect properly but never could get it to work at all.
RewriteCond %{QUERY_STRING} ^oPark=110246$
RewriteRule ^subdir1/subdir2/cond_e(.*) ^$? [NE, R=301, L]
What am I doing wrong? please help!
Try with below rule in subdir2,
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/cond_e.asp
RewriteCond %{QUERY_STRING} ^obark=[1]{1}[1-2]{1}[0]{1}[02-9]{1}[094-5]{1}[06-9]{1}
RewriteRule ^ http://www.DomainName.com? [R=301,L]
I would redirect with htaccess all codeigniter pages with following url to a coming soon page
*.domain.ext/customer/any_page
to /customer/comingsoon
any tips?
Why not use the routing facility in CodeIgniter?
$route['default_controller'] = 'customer/comingsoon';
or
$route['(:any)'] = 'customer/comingsoon';
Try this :
RewriteEngine on
RewriteCond %{REQUEST_URI} /(.*)
RewriteRule /(.*) http://domain.ext/customer/coomingsoon
We removed some old modules on our website and now google give us a lot of 404 error when he parse the website.
example :
best-sales.php?n=20&p=7
best-sales.php?n=10&p=39
best-sales.php?n=10&p=59
best-sales.php?n=20&p=32
...
I tried to redirect them to the index with htaccess and rewriterule like this
RewriteCond %{QUERY_STRING} ^n=20&p=7$
RewriteRule ^best-sales\.php$ /index.php [R=301,L]
but it always redirect to index.php?n=20&p=7 (with the old parameters)
Someone have an idea to redirect all pages like best-sales.php?XXXXXXXXXXXXX to index.php ?
Regards,
Fred
Sorry Please i am a new bie in url rewriting.
I have a url like this
http://www.sitename.com/subpages/detail.php?id=21-0043-052&car_name=abc
i want to redirect this site to
http://www.qualitextrading.com/vehicle-detail.php?id=21-0043-052&car_name=abc
Please how i can write this in .htaccess file
Thanks in advance
Assuming you have mod_rewrite enabled:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.sitename.com$ [NC]
RewriteRule ^\/subpages\/detail\.php(*.?)$ http://www.qualitextrading.com/vehicle-detail.php$1 [R=301,L]
This turns on rewriting for this area, then checks if the HTTP_HOST is correct, then rewrites the URL and passes on the query string (default behavior of mod_rewrite passes on query string automatically).
My client has gone through a rebrand and has changed their primary URL. I need to redirect all traffic that visits old URLs and send them to the same page on the new URL and ideally append a #hashtag... the hashtag will trigger an overlay explaining the redirect. Both sites are on the same Drupal codebase and thus use the same .htaccess file.
So if someone visits:
http://oldsite.com/abc/def
They should be redirected to:
http://newsite.com/abc/def/#hashtag
Any help would be greatly appreciated.
something like this?
Though I'm no expert when it comes to htaccess trickery.
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.newdomain\.com
RewriteRule (.*) http://www.newdomain.com/$1/#hashtag [R=301,L]