can this be done on a server with htaccess
-
Abby
- Verified Member

- Posts: 674
- Joined: July 13th, 2018, 10:04 pm
- Title: No man pays my bills
can this be done on a server with htaccess
Have one htaccess file redirect all 404 pages to a url instead of adding an htacces file to each domain hosted on the server, and what would the htaccess file look like please.
- TheButcher
- Administrator

- Posts: 17533
- Joined: February 2nd, 2018, 11:48 am
- Title: I like weekends
- Referrals: 1
- Contact:
I know whatever you do with htaccess you can not get 404 pages on phpbb to go to another url other than the root of the domain, I prefer using individual htaccess files per site because some scripts require certain lines of code.
-
Abby
- Verified Member

- Posts: 674
- Joined: July 13th, 2018, 10:04 pm
- Title: No man pays my bills
- HeidiHoe
- Verified Member

- Posts: 1653
- Joined: February 3rd, 2018, 12:20 pm
- Title: Resident Genius
Can .htaccess reside above domain level? That's what you'd have to do to control all domains with one file. You might be able to modify your server settings to do this. If you're running CMS, for example wordpress, you would want to make sure you're not creating any conflicts by doing this. Why would you want to do this anyway? It's one lousy line of code in one file per domain. Why give up the flexibility and cause potential issues?
The Fourth Turning Is Here
- HeidiHoe
- Verified Member

- Posts: 1653
- Joined: February 3rd, 2018, 12:20 pm
- Title: Resident Genius
Not something that I'd recommend but i guess you could just add a meta refresh tag to your 404 page.
The code goes in the head but will work when placed anywhere.
Code: Select all
<meta http-equiv="refresh" content="0;URL='https://domain.com/page'" />The Fourth Turning Is Here
-
Abby
- Verified Member

- Posts: 674
- Joined: July 13th, 2018, 10:04 pm
- Title: No man pays my bills
- gspotman
- Verified Member

- Posts: 1417
- Joined: June 6th, 2018, 7:42 pm
My hosting control panel adds a htacess file when I add a new domain to my server.
Teams: 60c094411cbb39b8
Email: gspotman@gmx.com
Email: gspotman@gmx.com
- HeidiHoe
- Verified Member

- Posts: 1653
- Joined: February 3rd, 2018, 12:20 pm
- Title: Resident Genius
Within the domain folder, not above it. It controls one particular domain, not all of the domains on the server. Anytime you add domain specific settings in your control panel, such as redirect www for example, a .htaccess file is created containing the directive.
Also, if you manually edit the file removing the code or delete the file altogether, you'll see that the settings in your control panel has changed.
The Fourth Turning Is Here
- tacnet
- Board Sponsor

- Posts: 3641
- Joined: February 22nd, 2019, 7:21 pm
- Referrals: 9
- Contact:
You can do this in the http.conf file but htaccess files are specific to the domain
Just put this in your htaccess
ErrorDocument 404 https://www.domain.com/404page.html
Just put this in your htaccess
ErrorDocument 404 https://www.domain.com/404page.html
- gspotman
- Verified Member

- Posts: 1417
- Joined: June 6th, 2018, 7:42 pm
I mean per domain not all sites hosted on the same serverHeidiHoe wrote: ↑November 28th, 2022, 9:46 amWithin the domain folder, not above it. It controls one particular domain, not all of the domains on the server. Anytime you add domain specific settings in your control panel, such as redirect www for example, a .htaccess file is created containing the directive.
Also, if you manually edit the file removing the code or delete the file altogether, you'll see that the settings in your control panel has changed.
Teams: 60c094411cbb39b8
Email: gspotman@gmx.com
Email: gspotman@gmx.com
- HeidiHoe
- Verified Member

- Posts: 1653
- Joined: February 3rd, 2018, 12:20 pm
- Title: Resident Genius
Yep. OP wants to set 404 for all domains with one .htaccess file instead of changing server settings. Tacnet replied with the specific file on the server that needs to be modified to accomplish what the OP wants to do. Not a good idea, but whatevergspotman wrote: ↑November 29th, 2022, 8:46 amI mean per domain not all sites hosted on the same serverHeidiHoe wrote: ↑November 28th, 2022, 9:46 amWithin the domain folder, not above it. It controls one particular domain, not all of the domains on the server. Anytime you add domain specific settings in your control panel, such as redirect www for example, a .htaccess file is created containing the directive.
Also, if you manually edit the file removing the code or delete the file altogether, you'll see that the settings in your control panel has changed.
The Fourth Turning Is Here
-
Hosting Fred
- Verified Member

- Posts: 320
- Joined: October 12th, 2021, 8:43 am
- Title: Hosting is my game
If you are running the same scripts on the server itwould be okay but if not then do it the usual way , add a .htaccess file per site,my 2 cents.
-
XpressPete
- Verified Member

- Posts: 768
- Joined: April 20th, 2018, 7:39 am
why would you want to do it that way?
- AlexO
- Verified Member

- Posts: 6409
- Joined: February 10th, 2018, 5:37 pm
- Title: I like Celebrities
This has me thinking can you put a wild card htaccess on the server in the public_html level instead?
Give me celebrity porn 
- HeidiHoe
- Verified Member

- Posts: 1653
- Joined: February 3rd, 2018, 12:20 pm
- Title: Resident Genius
.htaccess needs to reside in the domain root of the domain it applies to. When your site loads for a visitor, it will look for .htaccess within the publicly accessible files for the website. That's the domain root folder, not above.
You can store files above that level and link them for download thus preventing direct web access but I don't think you can rig anything similar for .htaccess. Not as far as I know anyways.
If you place .htaccess within a directory folder inside the domain root, it will control anything located within that directory.
The Fourth Turning Is Here