我需要为mod_rewrite制定规则:
这
http://site.kiev.ua/index.php
http://www.site.kiev.ua/
http://www.site.kiev.ua/index.php
到
http://site.kiev.ua/
这
http://site.kiev.ua/catalog/products/941
到
http://site.kiev.ua/catalog/products/941/
这
http://site.kiev.ua/catalog/products/941/index.php
到
http://site.kiev.ua/catalog/products/941/
941 - 它可以是任何类别
答案 0 :(得分:1)
RewriteEngine On
RewriteBase /
# www to none www
RewriteCond %{HTTP_HOST} ^www.domain.com [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [L,R=301]
# Remove index.php
RewriteCond %{THE_REQUEST} \ /(.+/)?index\.(html?|php)(\?.*)?\ [NC]
RewriteRule ^(.+/)?index\.(html?|php)$ ./$1 [R=301,L]
# Force trailing slashes.
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]
# /file.php to /file/
RewriteCond %{REQUEST_URI} ^(/.*[^/])/?$
RewriteCond %{DOCUMENT_ROOT}%1.php -f
RewriteRule ^([^/]+)/?$ ./$1.php [QSA,L]
答案 1 :(得分:0)
Options +FollowSymlinks -Indexes
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.site\.kiev\.ua$ [NC]
RewriteRule ^(.*)$ http://site.kiev.ua/$1 [L,R=301]