Currently when i enter the wrong url for example https://www.example.com/1234 then it redirect to 302 and then redirect to 404 page.
I need to directly redirect to 404 error page for SEO purpose.
I have also tried with below solution in htaccess.
If rewrite mod isn't enabled
ErrorDocument 404 /index.php?controller=404
Please help me with solution.
Thanks in advance.
try in your backoffice :
Shop parameters -> Traffic & SEO
In block -> Set up URLs
Redirect to the canonical URL : 301 Moved Permantly
Related
I want to change an existing Magento store to add store/lang codes to the url i.e.
http://mystore/en/PRODUCTXYZ.html
http://mystore/de/PRODUCTXYZ.html
Old links to http://mystore/PRODUCTXYZ.html will now throw a 404 error.
How can I create an Apache url rewrite rule to add a language code if it is missing i.e. rewrite
http://mystore/PRODUCTXYZ.html
to
http://mystore/de/PRODUCTXYZ.html
So that old links 301 redirect to the correct product.
I have worked around this with
Redirect 301 /PRODUCTXYZ http://mystore/de/PRODUCTXYZ.html
But obviously for thousands of products this might not be practical.
You can redirect multiple Product.html urls with just 1 line of code using RedirectMatch :
RedirectMatch 302 ^/([^/.]+)\.html$ http://example.com/de/$1.html
I used 302 for testing purposes and to avoid browser's cache,
change 302 to 301 (permanent redirect) when you are sure the redirect is working.
can I vía .htaccess redirect when
Users finds an Internal Server Error
A not found page
Is that posible? if so, can someone help me with the rewrite rules?
edit
trying
ErrorDocument 500 /oohps.php
ErrorDocument 404 /where.php
and adding them at domain.com/oops.php and domain.com/where.php but still not loaded
Why not just use custom error responses via ErrorDocument?
ErrorDocument 500 /errors/internal-server-error.html
ErrorDocument 404 /errors/not-found.html
It is useful I am able to redirect to index page on 404 error(page not found) by modifying "ErrorDocument" in /etc/apache2/conf.d/localized-error-pages file.
Thanks.....
I am redesigning my website and in the process restructuring some of the linking structure.
To do the permanent redirects I am using the following code (.htaccess)
RedirectMatch permanent old-link($|\.html) http://thedomain.com/new-link.url
I am using a CMS and changing the link for a category changes the path of the url like so:
thedomain.com/old-category-link/old-article-url.html
to
thedomain.com/new-category-link/old-article-url.html
How should I code (.htaccess) the redirect of any URL that has
thedomain.com/old-category-link
(i.e
thedomain.com/old-category-link/old-article.html
thedomain.com/old-category-link/old-article-2.html
thedomain.com/old-category-link/old-article-999.html
)
to
thedomain.com/new-category-link/any-articles-old-url.html
Thank you
Not exactly sure what you are asking to be redirected to, but is it something like this?
RedirectMatch permanent old-category-link(.*) http://thedomain.com/new-category-link$1
This will make is so if someone requests:
http://thedomain.com/old-category-link they will get redirected to http://thedomain.com/new-category-link
http://thedomain.com/old-category-link/ they will get redirected to http://thedomain.com/new-category-link/
http://thedomain.com/old-category-link/article1.html they will get redirected to http://thedomain.com/new-category-link/article1.html
http://thedomain.com/old-category-link/article50.html they will get redirected to http://thedomain.com/new-category-link/article50.html
No answer worked for me. Here is what is working with my Wordpress site.
Example:
OLD URL: http://website.com/xxx/yyy/picture.png
NEW URL: http://website.com/wp-content/picture.png
So, I want to replace /xxx/yyy/ with the normal /wp-content/ path of WordPress.
Put this in your .htaccess file.
RewriteEngine on
RedirectMatch 301 /xxx/yyy/(.*) http://website.com/wp-content/$1
My site has just recently launched a bunch of new product pages, replacing the old ones.
Here is an example of a redirect I want. One going from the old page...redirecting to the new page. I checked Google webmaster and said that there was a not found error for the second link.
Redirect 301 /it-infrastructure.html http://www.example.com/managed-enterprise-services.html
Redirect 301 /it-infrastructure http://www.example.com/managed-enterprise-services.html
So the .html one is redirecting fine...but the one without the .html extension is not. BUT...what's strange is that I have a bunch of redirects from the past that don't use the html ext and work fine, such as:
Redirect 301 /broadsoft-web-portal http://www.example.com/broadsoft-web-portal.html
and
Redirect 301 /business-voip http://www.example.com/business-voip.html
Anyone have any idea why this isn't working?
Add to your .htaccess this line
Options -MultiViews
Hey guys, have a question regarding apache. I have a site that's been re-engineered, but I want to capture all the 'old' links that people may have bookmarked or come from search engines to the old site which is under a new domain name. How do I get apache to redirect only 404 not found to the old site?
TIA,
J
You should first decide what status code you want to send. Sending both a 404 status code and a redirect is not possible.
But seth did already mention the right method, the ErrorDocument directive:
# local path
ErrorDocument 404 /local/path/to/error/document
# external URI
ErrorDocument 404 http://uri.example/to/error/document
If you use a local path, the 404 status code is sent. If you use an absolute URI, a 302 status code (temporary redirect) is sent.
And if you want to send a 301 redirect:
Redirect 301 / http://new.example.com/
Your old domain should capture all responses and return a '301 moved permanently' response with the new domain in the 'Location' field of the header. A 404 means 'not found' and in this case it's not strictly true.
Another option, similar to that proposed by #seth is to add the handler so it points to a static html page which you can use to explain to the user what happen, and present them with options.
You can include a meta redirect so that if they don't do anything after a few seconds they're automatically redirected.
Which option will work best is really up to you do decide.
You could set your 404 document to a CGI that redirects the user.
ErrorDocument 404 /cgi-bin/redirect-to-other.cgi