Jump to content

How to do this: htaccess to only show correct url


OllieMackJames
 Share

Recommended Posts

In my visitor stats I just found a strange string added to my url

www.domain.com/name-of-page/?sa=X&ved=0CDwQ9QEwEzigAWoVChMIyOTM7sb-xgIVy-8UCh2tBwDi

Here's the question: how can I get processwire to not keep the url like that?

I am already working with canonical, but also want htaccess rewrite or something to take care of this.

Anyone know how to do this?

thanks!

Link to comment
Share on other sites

With these, it's best to tackle them one by one. For this particular one, place the following directly beneath RewriteEngine On:

RewriteCond %{QUERY_STRING} ^sa=[^&]+&ved=[^&]$ [NC]
RewriteRule ^(.*)$ /$1? [R=302,L]

This will trim out the query string and revert to /name-of-page.

  • Like 2
Link to comment
Share on other sites

With these, it's best to tackle them one by one. For this particular one, place the following directly beneath RewriteEngine On:

RewriteCond %{QUERY_STRING} ^sa=[^&]+&ved=[^&]$ [NC]
RewriteRule ^(.*)$ /$1? [R=302,L]

This will trim out the query string and revert to /name-of-page.

Thanks Mike, that seems to do the trick for this one.

Still wondering though, I managed to get all in one go, but lost access to the admin side of pw, would anyone know how to do this.

Maybe do admin on https? Site itself runs on http.

Anyone any ideas?

thanks!

Link to comment
Share on other sites

You could limit the removal of get parameters to just the frontend by disabling the rule for everything in the admin-backend "folder". Disabling them in the backend is a very bad idea as lots of core and 3rd party modules use them. 

  • Like 2
Link to comment
Share on other sites

You could limit the removal of get parameters to just the frontend by disabling the rule for everything in the admin-backend "folder". Disabling them in the backend is a very bad idea as lots of core and 3rd party modules use them. 

HI LostKobrakai, tnx for that, sounds good!

Now if only I knew how to do that, can you give an example that might work?

The code below blocks all get parameters, what do I need to add or change to exclude admin-backend folder?

thanks!

RewriteCond %{query_string} .
RewriteCond %{THE_REQUEST} !^.*\/piwik/index\.php?(.*)
RewriteRule (.*) /$1? [R=301,L]
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...