Hur skapar jag egna 40x sidor med mitt Unix WebbMotellkonto?

För Apache på Linux kan egna 40x sidor skapas med .htaccess.

 This seems to be what people think htaccess was meant for, but it is only part of the general use. We'll be getting into progressively more advanced stuff after this.

In order to specify your own ErrorDocuments, you need to be slightly familiar with the server returned error codes. (List to the right). You do not need to specify error pages for all of these, in fact you shouldn't. An ErrorDocument for code 200 would cause an infinite loop, whenever a page was found...this would not be good.

You will probably want to create an error document for codes 404 and 500, at the least 404 since this would give you a chance to handle requests for pages not found. 500 would help you out with internal server errors in any scripts you have running. You may also want to consider ErrorDocuments for 401 - Authorization Required (as in when somebody tries to enter a protected area of your site without the proper credentials), 403 - Forbidden (as in when a file with permissions not allowing it to be accessed by the user is requested) and 400 - Bad Request, which is one of those generic kind of errors that people get to by doing some weird stuff with your URL or scripts.

In order to specify your own customized error documents, you simply need to add the following command, on one line, within your htaccess file:

ErrorDocument code /directory/filename.ext
or
ErrorDocument 404 /errors/notfound.html
This would cause any error code resulting in 404 to be forward to yoursite.com/errors/notfound.html

Likewise with:
ErrorDocument 500 /errors/internalerror.html

You can name the pages anything you want (I'd recommend something that would prevent you from forgetting what the page is being used for), and you can place the error pages anywhere you want within your site, so long as they are web-accessible (through a URL). The initial slash in the directory location represents the root directory of your site, that being where your default page for your first-level domain is located. I typically prefer to keep them in a separate directory for maintenance purposes and in order to better control spiders indexing them through a ROBOTS.TXT file, but it is entirely up to you.

If you were to use an error document handler for each of the error codes I mentioned, the .htaccess file would look like the following (note each command is on its own line):

  ErrorDocument 400 /errors/badrequest.html
ErrorDocument 401 /errors/authreqd.html
ErrorDocument 403 /errors/forbid.html
ErrorDocument 404 /errors/notfound.html
ErrorDocument 500 /errors/serverr.html


You can specify a full URL rather than a virtual URL in the ErrorDocument string (http://yoursite.com/errors/notfound.html vs. /errors/notfound.html). But this is not the preferred method by the server's happiness standards.

You can also specify HTML, believe it or not!

  ErrorDocument 401 "

You have
 to actually BE a member to view
this page, Colonel!


The only time I use that HTML option is if I am feeling particularly saucy, since you can have so much more control over the error pages when used in conjunction with xSSI or CGI or both. Also note that the ErrorDocument starts with a " just before the HTML starts, but does not end with one...it shouldn't end with one and if you do use that option, keep it that way. And again, that should all be on one line, no naughty word wrapping!

Next, we are moving on to password protection, that last frontier before I dunk you into the true capabilities of htaccess. If you are familiar with setting up your own password protected directories via htaccess, you may feel like skipping ahead.

 Successful Client Requests
200 OK
201 Created
202 Accepted
203 Non-Authorative Information
204 No Content
205 Reset Content
206 Partial Content
Client Request Redirected
300 Multiple Choices
301 Moved Permanently
302 Moved Temporarily
303 See Other
304 Not Modified
305 Use Proxy
Client Request Errors
400 Bad Request
401 Authorization Required
402 Payment Required (not used yet)
403 Forbidden
404 Not Found
405 Method Not Allowed
406 Not Acceptable (encoding)
407 Proxy Authentication Required   
408 Request Timed Out
409 Conflicting Request
410 Gone
411 Content Length Required
412 Precondition Failed
413 Request Entity Too Long
414 Request URI Too Long
415 Unsupported Media Type
Server Errors
500 Internal Server Error
501 Not Implemented
502 Bad Gateway   
503 Service Unavailable   
504 Gateway Timeout   
505 HTTP Version Not Supported   

  • 6 användare blev hjälpta av detta svar
Hjälpte svaret er?

Relaterade artiklar

Lösenordsskydda katalog

För att lösenordskydda en katalog med .htaccess rekommenderar vi Webmaster...

URL-omdirigering

Det är med en .htaccess-fil möjligt att dirigera om trafik till annan URL. Med t.ex....

Webbstatistik

Fri webbstatistik finns att tillgå för samtliga webbplatser, Apache. Webbstatistiken är åtkomlig...

Har ni några exempel på hur man gör databaskopplingar i mina skript?

Vi rekommernderar att ni besöker http://www.connectionstrings.com/. Där finns...

Apache Permissions plan WebbMotell

Unix File System Permissions Please refer to Notation of traditional Unix permissions for an...


WebbMotell - Det prisvärda alternativet för era hemsidor

Grymt Koncept! Vårt Premium webbhotellkonto är något utöver det vanliga. Ni får en helt egen server för er själv. Ni konkurrerar inte med någon annan om CPU och minne, allt är ert! Och detta till ett pris som motsvarar ett vanligt webbhotell.

Vi erbjuder också två instegskonton, Start och Standard från 99 kr per ÅR!. Dessa är vanliga webbhotellkonton där ni delar resurser som CPU och minne/RAM med andra kunder.

Beställ WebbMotell Här.

Lättanvänd och kraftfull

Vi har utvecklat en egen kontrollpanel för våra WebbMotellplaner. Med den går det att skapa och ta bort webbplatser, e-postkonton, administrera DNS, installera programvara med Installatron, ansluta sig med FTP till webbplatsen och en del till.

Den är så enkel att använda att i stort sett vem som helst klarar av att hantera sitt webbmotellkonto. För det absolut mesta ni behöver göra räcker det med vår Enkla kontrollpanel.

För de mer avancerade planerna ingår utöver den enkla kontrollpanelen den mer avancerade kontrollpanelen ISPConfig. Detta är en kontrollpanel som har sina rötter i Tyskland och utvecklingen av denna drivs också främst från Tyskland. Det innebär att den i mångt och mycket är utvecklad med europeiska ögon, vilket inte minst är viktigt ur ett GDPR perspektiv.

ISPConfig är en avancerad kontrollpanel med vilken man kan utföra komplexa inställningar, ofta inställningar som kräver lite kännedom om teknik. För den tekniskt bevandrade är ISPConfig ett grymt bra verktyg.

Även den mindre tekniskt insatte kan självklart använda ISPConfig. Inte allt är komplext och svårt, snarare så att det mesta är enkelt och det finns möjligheter till att göra mer komplexa inställningar. Vi har skapat en Supportportal som innehåller artiklar och hjälp. Det går också att ställa frågor i denna portal, frågor som vår supportpersonal då kommer att besvara

Utvecklarvänlig

Våra avancerade webbmotellplaner är perfekt för webbutvecklare. Ni har tillgång till ssh, ni kan installera ramverk, Laravel, CakePHP, Symfony, Zend Framework, Smarty osv osv. Composer finns också.

Vidare kan ni lägga in egna Apache- och PHP-direktiv för varje enskild webbplats.

Vi erbjuder också staging för WordPress utveckling. Ni kan ändra er WordPress, t.ex. ändra teman, installera moduler, utan att era besökare ser det. Era besökare ser bara er ursprungliga webbplats. När ni är nöjd med alla ändringar, då släpper ni enkelt era förändringar till produktionssidan och då är det det som er besökare ser.

Alla applikationer som ni installerar med installatron kan ni närsomhelst ta en ögonblicksbild av. Det kan vara bra om någon förändring ni gjort inte fungerade och ni behöver backa.

Väljer ni en plan med egen server då får ni också tillgång till redis cache. Ni kan själv använda det i er egen programutveckling, eller ni kan använda färdiga plugins till t.ex. WordPress. Ni kan då bygga ultrasnabba webbsidor som hämtar sitt innehåll från minnet istället för disk. För WordPress kan detta få en oerhörd betydelse.

Våra servrar är optimerade för hemsidor byggda med php, vi använder Apache med event-mpm och php-fpm. Vi erbjuder emellertid Nginx (Engine X) till våra Premium planer, för hemsidor som har oerhört många besökare och då behöver extra prestanda.

Beställ WebbMotell Här.