2
RewriteEngine On
RewriteCond %{HTTP_HOST} !.com$ //redirect from .net and .org to .com
RewriteRule .* http://www.domain.com%{REQUEST_URI} [R=301]
RewriteCond %{HTTP_HOST} !^www\. [NC] //Always use www.
RewriteRule ^/(.*)$ http://www.%1/$1 [R=301]
RewriteRule ^/?article-(.*)$ article.php?id=$1 [L,QSA,NC] // redirect article-x to article.php?id=x
RewriteRule ^/?page-(.*)$ page?p=$1 [L,QSA,NC]// redirect page-x to page.php?p=x
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php [L] // add the .php to every request if the file type is missing
除了添加www以外,所有规则都可以正常工作。到网址。例如3210 并不重定向到http://www.domain.com/page-1重写规则组合不起作用
.net到.com重定向工作正常,但我仍然可以访问网站没有www。 – nullException
这是在.htaccess中还是在'VirtualHost'配置中? –
.htaccess在我的主机 – nullException