我无法将我的域名ip重定向到域名,我的htaccess文件中有以下内容,我告诉它应该工作
RewriteCond %{HTTP_HOST} ^37\.61\.233\.81
RewriteRule (.*) http://jpcreativevision.co.uk/$1 [R=301,L]
但那不起作用,任何人都知道它为什么不起作用?谢谢你的帮助。
编辑 完整的htaccess
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
RewriteCond %{HTTP_USER_AGENT} libwww-perl.*
RewriteRule .* – [F,L]
RewriteCond %{HTTP_HOST} ^37\.61\.233\.81
RewriteRule (.*) http://jpcreativevision.co.uk/$1 [R=301,L]
RewriteCond %{HTTP_HOST} !^jpcreativevision\.co.uk
RewriteRule (.*) http://jpcreativevision.co.uk/$1 [R=301,L]
ErrorDocument 404 http://jpcreativevision.co.uk/404.php
答案 0 :(得分:0)
刚刚通过http://htaccess.madewithlove.be/对其进行了测试,结果表明您的规则应该按预期运行。
但是,您可以尝试不同的规则顺序:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^37\.61\.233\.81
RewriteRule (.*) http://jpcreativevision.co.uk/$1 [R=301,L]
RewriteCond %{HTTP_HOST} !^jpcreativevision\.co.uk
RewriteRule (.*) http://jpcreativevision.co.uk/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
RewriteCond %{HTTP_USER_AGENT} libwww-perl.*
RewriteRule .* – [F,L]
ErrorDocument 404 http://jpcreativevision.co.uk/404.php