Lavoro con un framework chiamato SilverStripe ... al momento stiamo migrando un vecchio sito su questo framework. Il problema è che i vecchi URL del sito terminavano con .php o .html mentre nel nuovo sito non lo erano..htaccess redirect .php e .html richieste
Ho bisogno di modificare la seconda regola di riscrittura in modo tale da pompare la richiesta su main.php senza estensioni .html o .php.
Nel mio .htaccess corrente ho le seguenti regole:
# Turn off index.php handling requests to the homepage fixes issue in apache >=2.4
<IfModule mod_dir.c>
DirectoryIndex disabled
</IfModule>
SetEnv HTTP_MOD_REWRITE On
RewriteEngine On
# Enable HTTP Basic authentication workaround for PHP running in CGI mode
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Deny access to potentially sensitive files and folders
RewriteRule ^vendor(/|$) - [F,L,NC]
RewriteRule silverstripe-cache(/|$) - [F,L,NC]
RewriteRule composer\.(json|lock) - [F,L,NC]
# Process through SilverStripe if no file with the requested name exists.
# Pass through the original path as a query parameter, and retain the existing parameters.
RewriteCond %{REQUEST_URI} ^(.*)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* framework/main.php?url=%1 [QSA]
# If framework isn't in a subdirectory, rewrite to installer
RewriteCond %{REQUEST_URI} ^(.*)/framework/main.php$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . %1/install.php? [R,L]
Possibile soluzione (ancora testare):
RewriteCond %{REQUEST_URI} ^(.*)\.html [OR]
RewriteCond %{REQUEST_URI} ^(.*)\.php [OR]
RewriteCond %{REQUEST_URI} ^(.*)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* framework/main.php?url=%1 [QSA]
@ 3dogo sfortunatamente la regola non si attiva –
Questo è strano. Funziona per me con i miei test. Ad esempio, se visito "www.example.com/about.html", verrà reindirizzato a "www.example.com/about". Un altro esempio 'www.esempio.com/about/team.php' verrà reindirizzato a' www.esempio.com/about/team'. – 3dgoo
con quale versione di Apache stai testando? –