URL's with ?attachment redirect instead of 404 http://www.customlogoshop.com/?attachment_id=719 - http-status-code-301

I want all http://www.customlogoshop.com/?attachment_id=719 these type of URL's to go to a 404 page but its just 301 redirect to my homepage.
It's only my URL's with '?attachment' that does this.
Thanks

I wondering the same, I got a url with ?attachment_id=000 to ?attachment_id=999 and i want all the url to go to a custom url.
I try something like this:
redirect 301 /?attachment_id=837 http://google.com
RewriteRule ?attachment_id(.*) / [R=301, L]

Related

How to redirect multiple URLs dynamically with htaccess?

How can I redirect each link/URL like https://example.com/blogspot/good-url to https://example.com/blog/good-url
In all links I just want to replace blogspot with blog Is this something we can achieve through .htaccess?
RedirectMatch 302 ^/blogspot/$ https://example.com/blog/$
also tried the below but doesn't seems to work:
RewriteRule ^/?blogspot/(.*)$ https://example.com/blog/$1 [R=301,L]
You can a simple Redirect for this
Redirect 302 /blogspot/ https://example.com/blog/
This will redirect all URLs from /blogspot/foobar to /blog/foobar .

.htaccess 301 redirect to site B with referrer from site A

I am trying to make the following redirection with .htaccess
Redirect 301 pageA.php to https://newSite/pageB.php?referrer=pageA.php
I need the pageA.php to be redirected to another site along with a referrer from the origin site containing pageA.php
Is there a way to do this in htaccess?
Try below code
RewriteRule ^/pageA.php https://newSite/pageB.php?referrer=pageA.php [R=301,L]

htaccess redirect 301 does not work

There was an old site, and all your URLs have changed.
One URL that was well found on Google was:
mydomain.com/datacenters
Now I want to redirect this URL to:
mydomain.com/data-centers
In htaccess I did:
redirect 301 /datacenters /data-centers
But it does not work, what am I doing wrong?
Only work with:
RewriteRule ^datacenters http://mydomain.bla/data-centers [L,R=301,NC]

Redirect www.domain.com/112 to www.domain.com/ using htaccess 301 redirect

I have thousands of URLs on my website like:
www.domain.com/112
and
www.domain.com/113
I'd like to redirect these straight to www.domain.com.
Can someone explain how I do this using the 301 Redirect with htaccess?
Thank you
RewriteEngine on
RewriteRule ^(\d+)/?$ / [R=301,L]
This will redirect any digit-based request in document root to index page

How to do 301 redirects with folders & subfolders?

I need to redirect all the old URLs on my site to new URLs, but am having issues. A given URL and its subfolders need redirecting to the same page.
For example, this is the first one:
redirect 301 /panache/sports-bra/ http://www.newdomain.co.uk/sports-bra.html
This works ok. However there are these size sub-pages which need to redirect to the same location:
redirect 301 /panache/sports-bra/30DD http://www.newdomain.co.uk/sports-bra.html
redirect 301 /panache/sports-bra/30E http://www.newdomain.co.uk/sports-bra.html
redirect 301 /panache/sports-bra/30F http://www.newdomain.co.uk/sports-bra.html
And these don't work, I end up at a location like the following:
http://www.newdomain.co.uk/sports-bra.html30DD
See the way the last part of the path is appended to the url? I'm guessing it's because the second redirect is conflicting with the initial 301 redirect?
I have also tried using this rewrite rule but have had no luck. The site is Magento so I don't know if this has some effect? mod_rewrite is enabled on the server.
RewriteRule ^panache/sports-bra/ http://www.newdomain.co.uk/sports-bra.html [R=301]
Any help mucha ppreciated.
Try this.
RewriteEngine on
RewriteRule ^(panache/sports-bra/.*)$ /sports-bra.html [L,R=301,NC]

Resources