我使用下面的代码将旧网站重定向到新网站。一切工作但我想要一个页面(PHP)不直接到新网站。我在这个网站和谷歌测试所有方式,但没办法工作!
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !new.com$ [NC]
RewriteRule ^(.*)$ http://new.com/$1 [L,R=301]
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^(.*)$ index.php?param=$1
RewriteCond %{HTTP_HOST} ^www\.old\.com [NC]
答案 0 :(得分:1)
要排除文件,请将以下条件置于规则上方:
RewriteCond %{REQUEST_FILENAME} !filename\.php$
你的htacess:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !new.com$ [NC]
RewriteCond %{REQUEST_FILENAME} !filename\.php$
RewriteRule ^(.*)$ http://new.com/$1 [L,R=301]
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^(.*)$ index.php?param=$1 [L]