I've found a few pages for redirecting a single page to 404 but it's not working. Here is my simple line
RedirectMatch 404 ^/showthread.php?p=3164554$
It does not work though. Am I missing something? Thanks!
Your configuration tries to redirect the page "404" to the page "^/showthread.php?p=3164554$" (see the documentation).
RedirectMatch generates a redirection : you can't redirect with a HTTP 404 code. When redirecting, you may have issues with the query string (I couldn't match the query string), I would use rewrite rules :
You can redirect to a 404.html page with
RewriteEngine On
RewriteCond %{QUERY_STRING} p=3164554
# the empty question mark discard the query string
RewriteRule ^/showthread\.php 404.html? [L,R=301]
Or you can stay on the same url but show the 404 page :
RewriteEngine On
RewriteCond %{QUERY_STRING} p=3164554
RewriteRule ^/showthread\.php - [L,R=404]
Try this way to escape your . character with \ like this.Let me know, it works for you or not.
RedirectMatch 404 ^/showthread\.php?p=3164554$
Related
I want to redirect a translated page to another translated page in the htaccess file.
In the original language it works (Redirect 301 /helpie_faq/what-are-my-benefits/ /faq/#hfaq-post-1683), but the redirection of translated pages doesn't work, e.g.
Redirect 301 /helpie_faq/welche-vorteile-erhalte-ich-als-neueinwanderer/?lang=de /faq/?lang=de#hfaq-post-3001
How can I make this work out?
You need to match on the query string, which the redirect directive does not support. Instead you should use RewriteCond on the URI (REQUEST_URI) and on the query string (QUERY_STRING) and a matching RewriteRule.
RewriteEngine On
RewriteCond %{REQUEST_URI} /helpie_faq/welche-vorteile-erhalte-ich-als-neueinwanderer$
RewriteCond %{QUERY_STRING} ^lang=de$
RewriteRule ^.*$ /faq/?lang=de#hfaq-post-3001 [L,R=301]
For more examples look here Apache Redirect 301 fails when using GET parameters, such as ?blah= or here Redirecting URLs (with specific GET parameters)
I have the following URL:
https://www.parcelparcel.com/nl_NL/pakket-versturen-frankrijk/?page=nl_NL/populair/pakket-naar-frankrijk/
Which I would like to 301 redirect to:
https://www.parcelparcel.com/nl_NL/pakket-versturen-frankrijk/
I tried to pull this off with the following code in my .htaccess:
RewriteRule ^index.php/populair/pakket-naar-frankrijk/?page=nl_NL/populair/pakket-naar-frankrijk/?$ https://www.parcelparcel.com/nl_NL/pakket-versturen-frankrijk/ [R=301,L]
However, without results. Can anybody advice me or tell me what I'm missing. I checked if the URL is redirected in incognito.
Thanks in advance!
Try This:
RewriteCond %{QUERY_STRING} !^(.*)$
RewriteRule ^nl_NL/pakket-versturen-frankrijk/?$ nl_NL/pakket-versturen-frankrijk/?page=nl_NL/populair/pakket-naar-frankrijk/ [L]
Fisrt line to exclude a request that has Query String
The second to choose a URI that starts with nl_NL/pakket-versturen-frankrijk/ or nl_NL/pakket-versturen-frankrijk and redirect it internally to nl_NL/pakket-versturen-frankrijk/?page=nl_NL/populair/pakket-naar-frankrijk/
I have a link like this:
http://www.expamle.com/folder1/folder2/folder%20/file.html
I want to 301 redirect it with .htaccess to:
http://www.expamle.com/folder1/folder2/folder/file.html
I tried this:
RewriteCond %{REQUEST_URI} ^\/folder1\/folder2\/folder\%20\/file\.html$
RewriteRule .* http://www.example.com/folder1/folder2/folder/file.html [R=301,L]
but I'm getting:
Not Found
The requested URL /folder1/folder2/folder /file.html was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
I also tried this
Redirect 301 /folder1/folder2/folder%20/Export1.htm http://www.example.com/folder1/folder2/folder/file.html
but got the same error.
What am I doing wrong?
The solution is to add quotes like this:
Redirect 301 "/folder1/folder2/folder /Export1.htm" http://www.example.com/folder1/folder2/folder/file.html
My wordpress website been hacked and google keeps crawling Urls with a certain parameter leis,
My question is, how to radirect to 404 any url containing leis parameter
Thanks in advance
how to radirect to 404 any url containing leis parameter?
You can use the following Rule for this :
RewriteEngine on
#If "leis" is present in the query string
RewriteCond %{THE_REQUEST} \?leis [NC]
#forword the request to 404
RewriteRule ^ - [R=404,L]
This is probably an easy question, but we can not find why the 301 is not working. When we have a url with a question mark the 301 redirect in our .htacces is not working. For example:
/order/order.html?AddID=1078&Rand=666171759380936096
so:
Redirect 301 /order/order.html?AddID=1078&Rand=666171759380936096 http://www.domain.nl
In our webmaster tools we have 8000 url's with the same structure /order/order.html?AddID=.... that say 404 not found. We want to 301 redirect them to the homepage, but we get a 404 not found page instead. when we use the same redirect with only /order/order.html he is redirected correct.
You can't match against the query string in a Redirect statement, use mod_rewrite and match against the %{QUERY_STRING} var:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^AddID=1078&Rand=666171759380936096$
RewriteRule ^order/order.html$ http://www.domain.nl/? [L,R=301]
But since you have like 8000 URLs that start with the query string ?AddID=, then you can just match against that:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^AddID=[0-9]
RewriteRule ^order/order.html$ http://www.domain.nl/? [L,R=301]
I have just tried it again and now I placed it right in the top of the htacces, see printscreen. In this case it is about the url (normally I do not place my own url) www.tablet.nl and if you place one of our 404 pages /order/order.html?AddID=1037&Rand=539054443213186002 behind the url, /order/order.html is deleted and only ?AddID=1037&Rand=539054443213186002 is shown behind the main url with a 404 page not found.
Any idea and I let the htacces as shown in the attachement so you can test the url.
Let me know