( , - ):
1. , :
RewriteCond %{HTTP_HOST} ^website.com
RewriteRule (.*) http://www.website.com/$1 [R=301,L]
RewriteRule somefile\.html$ - [L]
RewriteRule ^(.+)\.html$ http://www.website.com/$1.php [R=301,L]
, ( , , - URL- NO lead slash ):
RewriteRule ^full/path/to/somefile\.html$ - [L]
2. , :
RewriteCond %{HTTP_HOST} ^website.com
RewriteRule (.*) http://www.website.com/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule .+ - [L]
RewriteRule ^(.+)\.html$ http://www.website.com/$1.php [R=301,L]
3. , .html .php:
RewriteCond %{REQUEST_URI} !somefile\.html$
RewriteRule ^(.+)\.html$ http://www.website.com/$1.php [R=301,L]
, , ( , , - URL- )
RewriteCond %{REQUEST_URI} !^/full/url/path/to/somefile\.html$
4. , .html .php, .html :
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)\.html$ http://www.website.com/$1.php [R=301,L]
, .htaccess . .
source
share