AdWords invalid gclid htaccess - .htaccess

i keep getting an error from Google with the parameter gclid.
Here is my htaccess:
ReWriteRule ^([\w-]*)/*([\w-]*)/*([\w-]*)/*([\w-]*)/*([\w-]*)/*([\w-]*)/*([\w-]*)/*$ index.php?lang=$1&page=$2&spage=$3&ppage=$4&pppage=$5&ppppage=$6&gclid=$7
With this, i have urls like: https://domain.com/us/blog/whatever-deeplink-name
Can anyone help me how to fix this?

Adding [QSA,L] to the end of the line solved my issue.
ReWriteRule ^([\w-]*)/*([\w-]*)/*([\w-]*)/*([\w-]*)/*([\w-]*)/*([\w-]*)/*([\w-]*)/*$ index.php?lang=$1&page=$2&spage=$3&ppage=$4&pppage=$5&ppppage=$6&gclid=$7 [QSA,L]

Related

Redirecting a Domain with a Get Variable to a New Domain with the htaccess file

I am trying to send /bn/referral.php?id=xxxxx to https://www.newdomain.com/index.php?referral=xxxxx
I have it currently set up like this, with no luck:
RewriteRule ^/bn/referral.php?id=([0-9]+)$ https://www.newdomain.com/index.php?referral=$1 [NC,L]
Thanks in advance for any insight to this issue.
With your shown samples, attempts please try following .htaccess rules. Please make sure to clear your browser cache before testing your URLs. Also I am using here THE_REQUEST variable to handle both uri and query string together.
RewriteEngine ON
RewriteCond %{THE_REQUEST} \s/bn/(referral)\.php\?id=(\S+)\s [NC]
RewriteRule ^ https://www.newdomain.com/index.php?%1=%2 [R=301,L]

htaccess Rewrite Error, Can not fetch $_GET value PHP :(

I am sorry to open a replicated question once again but I had no other choice. I am trying to write a clean URL using .htaccess. Here is my code:
RewriteRule ^home index.php [NC,L]
RewriteRule ^about-us about-us.php [NC,L]
RewriteRule ^careers careers.php [NC,L]
RewriteRule ^contact-us contact-us.php [NC,L]
these works very finely. but when I move on to URL's having some GET params like
example.com/providers.php?provider=huawei
and the htaccess rule goes as:
RewriteRule ^providers/([a-zA-Z_-]+) providers.php?provider=$1 [NC,L]
When I navigate to the URL example.com/providers/huawei it throws an error
Notice: Undefined index: provider in directory\providers.php on line x
Appearantly, there is no error in the rule, I have gone through several video and StackOverflow solutions. Some suggested the use of QSA but no luck. I changed my production servers too still negative. Any help in this regard.
TIA

Mod_Rewrite with .htaccess is not working

I just learnt about url-rewrite for my website with .htacess. My actual url is:
localhost/index.php?view=some-page
So i write this RewriteRule like this:
RewriteRule ^/([^/]*)/?$ /index.php?view=$1 [NC,L]
When i typed localhost/homepage on my browser, It does not work, it displays error 404 object not found. What have i done wrong please show me.
Many thanks
This should work in your DocumentRoot/.htaccess:
RewriteEngine On
RewriteBase /
RewriteRule ^([^/]+)/?$ index.php?view=$1 [QSA,L]
Leading slash is not matched in htaccess.
are you using apache?
This link from step 6 helped me
https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-on-ubuntu-14-04
When i was playing around with rewrites i had to enable it and tell apache where the pages were stored

.htaccess change the URL page with three conditions

I want to change the url of my page like
http://localhost/Dynobase/my_computer.php?name=Deny-computer&type=computer&select=1
to
http://localhost/Dynobase/Deny-computer/computer/data/1
and to my htaccess file code like this
RewriteRule ^([a-zA-Z_-]+)/([a-zA-Z_-]+)/data/([[0-9]]+)$ /my_computer.php?name=$1&type=$2&select=$3 [L,NC]
but that I could actually error 404
maybe there is something wrong in my code.
please help me.
Thank you
Try this in /Dynobase/.htaccess:
RewriteEngine On
RewriteBase /Dynobase/
RewriteRule ^([\w-]+)/([\w-]+)/data/([0-9]+)/?$ my_computer.php?name=$1&type=$2&select=$3 [L,NC,QSA]

Redirect HTTP GET method to a different url using htaccess

I know this question is very basic but if someone could help me here, I would be very grateful.
I am trying to redirect all requests to http://example.com/index.php?/api/function to http://anotherexample.com/api/function using htaccess
I have been doing some research and all I find are redirect with the POST method but nothing really explained with GET.
I have tried:
RewriteBase /
RewriteRule ^index.php?/api/function http://anotherexample.com/api/function [NC,L,R=301]
this gives me no success.
Thanks in advance
I got it working with the code above:
RewriteCond %{QUERY_STRING} ^/api/(.*)$
RewriteRule ^index.php http://anotherexample.com/api/%1? [QSA,L]
thanks for the tip CBroe

Resources