简体   繁体   中英

Redirect IP address to domain name in .htaccess

I'm trying to redirect the IP address to the domain name of my website. This is my .htaccess file:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On

RewriteBase /

RewriteCond %{HTTP_HOST} ^198\.50\.227\.185 [nc]
RewriteRule ^(.*)$ http://www.allrealfood.com/$1 [r=301,nc,L]

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

I can't figure out how to get this to work.

301 (Permanent) Redirect:

Redirect 301 / http://mt-example.com/   

302 (Temporary) Redirect: Point an entire site to a different temporary URL.

Redirect 302 / http://mt-example.com/

Redirect index.html to a specific subfolder:

Redirect /index.html http://example.com/newdirectory/

Need to understand more go here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM