Chyba 404 na webhostingu – htacces?
- Vladik_hk
- Člen | 50
Ahoj, vim, ze se to tady uz nekolikrat resilo, ale ja porad nemuzu najit kde je problem. Presunul jsem aplikaci z localu na hosting a tam dostavam pro zadani jakekoli jine cesty nez adresy adresare document_root error 404. Tedy kdyz napr. www.xy.cz/…web/sign/in/ (pozn. je to zatim testovaci server, takze nemam nastavene na apachi smerovani do document_rootu a vypisuju takto primo celou adresu). Pokud zadam jen www.xy.cz/document_root/, nabehne mi alespon hlavni stranka.
Je to klasicky hosting, takze na serveru je korenovy adresar pojmenovany jako www/ a v nem mam pak document_root, app, atd. … V cem by mohl byt problem?
.htaccess soubor je klasicky:
<?php
# Apache configuration file (see httpd.apache.org/docs/2.2/mod/quickreference.html)
# disable directory listing
Options -Indexes
# allows symbolic links in this directory
Options +FollowSymLinks
# configure PHP
# <IfModule mod_php5.c>
# php_flag register_globals off
# php_flag zend.ze1_compatibility_mode off
# php_flag session.auto_start off
# </IfModule>
# enable cool URL
<IfModule mod_rewrite.c>
RewriteEngine On
# RewriteBase /
# front controller
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule !\.(pdf|js|ico|gif|jpg|png|css|rar|zip|tar\.gz)$ index.php [L]
</IfModule>
# default charset should be UTF-8
AddDefaultCharset utf-8
# enable gzip compression
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/x-javascript text/javascript application/javascript application/json
</IfModule>
# allow combined JavaScript & CSS. Inside of script.combined.js you could use <!--#include file="script.js" -->
<IfModule mod_include.c>
<FilesMatch "\.combined\.(js|css)$">
Options +Includes
SetOutputFilter INCLUDES
</FilesMatch>
</IfModule>
?>
Bootstra klasicky (pouzivam moduly):
<?php
require LIBS_DIR . '/Nette/Nette/loader.php';
Debug::$strictMode = TRUE;
Environment::getApplication()->catchExceptions = false;
// 2b) load configuration from config.ini file
$config = Environment::loadConfig();
// Step 3: Configure application
// 3a) get and setup a front controller
$application = Environment::getApplication();
$application->errorPresenter = 'Error';
//$application->catchExceptions = TRUE;
// Step 4: Setup application router
$router = $application->getRouter();
$router[] = new Route('index.php', array(
'module' => 'Web',
'presenter' => 'Homepage',
'action' => 'default',
), Route::ONE_WAY);
$router[] = new Route('<module>/<presenter>/<action>/<id>', array(
'module' => 'Web',
'presenter' => 'Homepage',
'action' => 'default',
'id' => NULL,
));
// Step 5: Run the application!
$application->run();
?>
Diky moc..
- h4kuna
- Backer | 740
Ahoj, já jsem měl problém s tím, že mi hosting neuznával kontejnery <IfModule mod_rewrite.c>, ale házelo mi to error 500.
- Pokud si myslíš že to je .htaccessem tak tam nechej nezbytné minimum
/*
RewriteEngine On
# RewriteBase /
# front controller
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule !\.(pdf|js|ico|gif|jpg|png|css|rar|zip|tar\.gz)$ index.php [L]
*/
- se doporučuje odkomentovat RewriteBase /, tzn smaž mřížku ‚#‘
- k té poslední routě, podle mě tam je k ničemu a možná taky to může zlobit, ta maska <module> nahradil bych ji takto
<?php
$router[] = new Route('<presenter>/<action>/<id>', array(
'module' => 'Web',
'presenter' => 'Homepage',
'action' => 'default',
'id' => NULL,
));
?>