我有重写规则,它对www以外的子域起作用。我要强制所有URL开始以www,并用PHP处理所有的.html:在.htaccess上重写规则重定向
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^catalog\.html$ http://www.domain.com/static.php?staticpage=$1 [L]
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule^http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
如果你打http://domain.com/catalog.html,它成功地重定向到http:// www.domain.com/catalog.html(当然没有空间),因为该文件不存在。或者,如果catalog.html存在,它将只显示http:// www.domain.com/catalog.html并呈现实际的.html文件(不含空格)。
我试图实现http://www.domain.com/catalog.html而不显示浏览器上的static.php,无论文件是否存在。 static.php应该处理每个.html页面
在此先感谢!