Redirecting 404 error with subdomain - .htaccess

How i redirect 404 page error subdomain link.
Example:
domain.com/46444
link show 404 not found.
How i redirect for
subdomain.domain.com/4644
This page i have normal page
subdomain.domain.com/4644
.htaccess link add one is not an option.
I have 200 000 link.

Related

if not found any page or url then redirect index.php

I want to redirect like http://localhost/project/g47sh to http://localhost/project/index.php
But when I am write on URL http://localhost/project/g47sh then 404 error is generated so I want to if any page or directory not found the redirect index.php and also pass not found URL path.

How can I redirect 301 all error pages to sub folder?

I want to redirect 301 with htaccess file my broken URLs. What do I mean? If visitor come to this link: http://mydomain.com/blablablablablablablabla34234234.php he probably will get an 404 error so I want my "404 page" will be in sub folder. like this:
http://mydomain.com/somenonpage.php to http://mydomain.com/sub/somenonpage.php
http://mydomain.com/blablablablabla to http://mydomain.com/sub/blablablablabla
etc.
If you want to have a custom 404 page you do not do a 301 Redirect, 301 is to redirect an old link to a new URL. Say you had a popular post but decided to change the url for SEO reasons but the old url was heavily backlinked. You would then use a 301 to make sure that those backlinks got associated with your new url.
To make a custom 404 all you need to do is edit your http.conf file and add a path to your custom 404 page. By default I think the file belongs in your root directory named 404.html.
If you need the fileto have a different name or location you can edit the file path at the line beginning line ErrorDocument 404 /404.html.

How to redirect 404 error page with 404 response code to a custom page using htaccess

I want to REDIRECT 404 error page to custom 404 page. For example, if http://example.com/abc.html causes 404 error, I want redirect the page to http://example.com/404.html with 404 http response code. It is possible?
So far there is NO OPTION to redirect 404 error page to a custom 404 page with 404 http response code. To get 404 http response code, you will need to display custom 404 error page content without redirection like following code:
ErrorDocument 404 /404.html
And if you use following code, the 404 error page will be redirected to the custom 404 page with 302 http response code
ErrorDocument 404 http://www.yourdomain.com/404.html
Since you are using Apache, you can use the ErrorDocument directive (docs).
You are encouraged to use an internal rewrite for this, so the client receives the correct statuscode for the request (404). If you make it redirect to this page, the client will receive a 301 or 302 header instead for the non-existing page, which can confuse automated webservices, such as webcrawlers.
To make it internally rewrite:
ErrorDocument 404 /404.html
To make it externally redirect
ErrorDocument 404 http://yoursite.com/404.html

.htaccess redirect subdomain 404 to main domain 404

I'm working with a site that used to use a subdomain to link to an externally hosted blog. This has since been deleted and incorporated into the main site. The subdomain now just houses a .htaccess file with 301 redirects for the blog articles.
I also have a 404 page set up for any other remaining links to the subdomain. The problem is that I want the 404 to be served from the main domain, not the subdomain. Instead of blog.example.com/404, I want to serve www.example.com/404.
Not sure if it matters, but on the server, my subdomain is a folder inside of the main domain:
html/ = www.example.com
html/blog/ = blog.example.com
Remove any 404 ErrorDocument line from DOCUMENT_ROOT/blog/.htaccess
In your DOCUMENT_ROOT/.htaccess add this line:
ErrorDocument 404 /blog/404.html

Redirecting bad url links from external sites with .htaccess

I have two inbound links that land on 404 pages because the links are squiffy. I have tried 301'ing these links as normal but without success, I believe because of the characters used from this external URL.
Column<u>Radiators.html
is the page suggested on this external site and
Column_Radiators.html
is the actual page.
also
Bath%3Cu%3EFiller.html
on the external site and
Bath_Filler.html
on our actual website.
How can I succesfully redirect these pages?
Simply add these lines in your .htaccess
redirect 301 /Column<u>Radiators.html /index.html
redirect 301 /Bath<u>Filler.html /index.html
Note: I use index.html as the default redirection but you can use a custom 404.

Resources