Problem s mod_rewrite u Onebit
Upozornění: Tohle vlákno je hodně staré a informace nemusí být platné pro současné Nette.
- frees
- Člen | 25
Dobry den, mam hosting od spolocnosti Onebit a vobec mi na nom nefunguju cool url a hosting vracia Apache chybu 404. Pouzivam Nette 2.0. Vedel by mi prosim niekto poskytnut navod, ako Nette nastavit tak, aby cool url fungovali? Prikladam aktualny .htaccess a bootstrap.php
HTACCESS
# Apache configuration file (see httpd.apache.org/docs/2.2/mod/quickreference.html)
# disable directory listing
Options -Indexes
# 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>
# 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>
BOOTSTRAP
<?php
/**
* My Application bootstrap file.
*/
use Nette\Application\Routers\Route,
Nette\Application\Routers\SimpleRouter;
// Load Nette Framework
require LIBS_DIR . '/nette.min.php';
require LIBS_DIR . '/dibi.min.php';
// Configure application
$configurator = new Nette\Config\Configurator;
// Enable Nette Debugger for error visualisation & logging
$configurator->enableDebugger();
// Enable RobotLoader - this will load all classes automatically
$configurator->setTempDirectory(__DIR__ . '/../temp');
$configurator->createRobotLoader()
->addDirectory(APP_DIR)
->addDirectory(LIBS_DIR)
->register();
// Create Dependency Injection container from config.neon file
$configurator->addConfig(__DIR__ . '/config/config.neon');
$container = $configurator->createContainer();
// Connect to database via DIBI
dibi::connect($container->params['database']);
// Setup router
if (function_exists('apache_get_modules') && in_array('mod_rewrite', apache_get_modules())) {
$container->router[] = new Route('index.php', 'Homepage:default', Route::ONE_WAY);
$container->router[] = new Route('<presenter>/<action>[/<id>]', 'Homepage:default');
} else {
$container->router = new SimpleRouter('Homepage:default');
}
// Configure and run the application!
PavelMaca\Captcha\CaptchaControl::register();
\Nette\Forms\Container::extensionMethod('addDatePicker', function (\Nette\Forms\Container $container, $name, $label = NULL) {
return $container[$name] = new \JanTvrdik\Components\DatePicker($label);
});
$container->application->run();
- Snikwah
- Člen | 6
Ahoj,
máš zapnuté mod_rewrite v administraci OneBitu? Pokud nevíš o čem
mluvím, tak se mkrni zde https://www.oneadmin.cz/…-mod_rewrite (musíš být
příhlášen v ONEadmin.cz).
Jinak zde dávám výpis .htaccess, které mně funguje u OneBitu, když používám Nette 2.0.4:
# Apache configuration file (see httpd.apache.org/docs/2.2/mod/quickreference.html)
# disable directory listing
Options -Indexes
# 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>
# 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>