remove dynamic part of url .htaccess - .htaccess

I need to remove the dynamic part of a url:
example.com/pagename/?btag=a_233b_230c_&affid=201
so remove everything after and including "?"
But I don't want this rule to apply to this directory:
example.com/wp-content/?attr=1345
Is it possible to do this with .htaccess?
Thanks, any help is appreciated
Jon

RewriteCond %{REQUEST_URI} !^/wp-content
That might help:-d just repeat for other folders.

Related

Remove additional text after last parameter in address bar with .htaccess

I have this rule in .htaccess:
RewriteRule ^files/page/?([0-9]+)? /files?page=$1 [QSA,L]
which allows to access different pages like files/page/2
problem is, it also allows for files/page/2/2/2/2/2/2/2/2/2 and so on.
How do I remove the repeating /2/2/2/2 ?.. Tried different solutions but they didn't work out.
Yes, very sorry, such a silly mistake!
It needs to be:
RewriteRule ^files/page/([0-9]+)$ /files?page=$1 [QSA,L]

.htaccess COMPLEX redirect and replace value + html

I tried to search all pages but nothing to do for my request.
I need to REDIRECT the comlex link cause GOOGLE duplicate descriptions.
from:
http://www.3dstreaming.org/component/community/5816-stuart-edwards/profile.html?Itemid=0
to:
http://www.3dstreaming.org/you/edit-profile/5816-stuart-edwards.html
CONDICTIONS:
where "5816-stuart-edwards" is variable
part of the URL from "component/community" to "you/edit-profile"
replace from "5816-stuart-edwards/profile.html?Itemid=0" to "55816-stuart-edwards.html"
Many many thanks in advance.
Try the following:
RewriteEngine On
RewriteRule ^component/community/(.*)/profile.html$ /you/edit-profile/$1.html? [R]
RewriteRule ^you/edit-profile/(.*).html /component/community/$1/profile.html [L]
The above should change http://www.3dstreaming.org/component/community/5816-stuart-edwards/profile.html?Itemid=0 to: http://www.3dstreaming.org/you/edit-profile/5816-stuart-edwards.html

htaccess rules to redirect in the same directory

I am new in htaccess rules. I have tried to search about my question but couldn't get the answer.
I have got a url like this mysite.it/test/libro/la-missione-cristiana/1959 and I would like to rewrite to mysite.it/test/index.php?page=libro&id=1959
I have the following htaccess file in my root folder and I have added the following line:
RewriteRule ^test/libro/([^/.]+)/([^/.]+) test/index.php?page=libro&id=$2 [QSA,L]
but It doesn't work.
I would really appreciate if someone could explain me the cause.
Thank you,
your match all but slash group '([^/.]+)' appears to group all non-slash and non-any-character, thus it will not match anything as the . matches any, and the plus require at least one match.
try remove the dots
RewriteRule ^test/libro/([^/]+)/([^/]+) test/index.php?page=libro&id=$2 [QSA,L]
should work for you.

want to replace .index.php?backLinks_free_Backlinks=1&totalRows_free_Backlinks=7 part by /backLinks_free_Backlinks/1 from my url using .htaccess

i have a link look like this
http://backlinks.cheapratedomain.com/index.php?backLinks_free_Backlinks=1&totalRows_free_Backlinks=7
want to replace .index.php?backLinks_free_Backlinks=1&totalRows_free_Backlinks=7 this part by /backLinks_free_Backlinks/1 using .htaccess
after replacing link will be look like this
http://backlinks.cheapratedomain.com/backLinks_free_Backlinks/1
Try adding this to your htaccess file in the document root:
RewriteEngine On
RewriteRule ^backLinks_free_Backlinks/([0-9]+)$ /index.php?backLinks_free_Backlinks=$1&totalRows_free_Backlinks=7 [L,QSA]
You can remove the &totalRows_free_Backlinks=7 bit from the target if you don't need it.

.htaccess Redirect sub-folder

Hi I'm not a programmer by any stretch of the imagination and am trying to do a multi 301 redirect in my htaccess file based on the following:
So I have a ton of urls all with similar naming conventions - here is a sample of 2.
http://www.hollandsbrook.com/garrett-at-gold/
http://www.hollandsbrook.com/garrett-ace-250/
These urls need to redirect to:
http://www.hollandsbrook.com/garrett-metal-detectors/garrett-at-gold/
http://www.hollandsbrook.com/garrett-metal-detectors/garrett-ace-250/
I could just redirect them 1 line at a time, but I'd like to use regex.
Here's what I was thinking so far but not working:
RewriteRule ^garrett-([a-z])/$ /garrett-metal-detectors/$1/ [R]
Basically i need to redirect any page right off the root that starts with "garrett-" to include the folder path of "garrett-metal-detectors".
Any thoughts would be MUCH appreciated. Many thanks in advance for your help.
if you want temprorary redirect use:
RewriteRule ^garrett\-([a-z0-9\-]+)/?$ /garrett-metal-detectors/garrett-$1/ [R=302,L]
if you want permanent redirect use:
RewriteRule ^garrett\-([a-z0-9\-]+)/?$ /garrett-metal-detectors/garrett-$1/ [R=301,L]
I'm am not an expert on Regular Expressions, but looks like your reg ex may be a bit off...
try:
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^((garrett)(-[a-z0-9]).*)/$ /metal-detectors/$1/ [R]
This is looking fro anything starting with "garrett" followed by any letter/number/hyphen combo.
Note: having "garett" in the destination part give you a loop of redirects, so you may have to choose a different word, or remove it all together...

Resources