2016-04-23 79 views
0

我想重定向我的IP地址到我的域名使用.htaccess文件,但它似乎並沒有工作。除此之外,我還想將我的https鏈接重定向到http站點。任何人都可以幫忙IP地址重定向到域名使用共享主機上的.htaccess

我的.htaccess文件看起來像這樣


Options -Indexes 

ErrorDocument 404 /404.php 
ErrorDocument 403/

<FilesMatch "\.inc.php"> 
    order deny,allow 
    deny from all 
</FilesMatch> 

## SEO Friendly URLs ## 
RewriteEngine On 

RewriteCond %{HTTP_HOST} ^111\.11\.111\.11$ 
RewriteRule (.*) http://www.domainname.com/$1 [R=301,L] 


RewriteRule ^(admin)($|/) - [L] 
## hide .php extension 
# To externally redirect /dir/foo.php to /dir/foo 
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC] 
RewriteRule^%1 [R,L,NC] 
## To internally redirect /dir/foo to /dir/foo.php 
RewriteCond %{REQUEST_FILENAME}.php -f 
RewriteRule^%{REQUEST_URI}.php [L] 


RewriteCond %{HTTP_USER_AGENT} libwww-perl.* 
RewriteRule .* ? [F,L] 

<IfModule mod_expires.c> 
    ExpiresActive on 

    ExpiresByType image/jpg "access plus 1 month" 
    ExpiresByType image/jpeg "access plus 1 month" 
    ExpiresByType image/gif "access plus 1 month" 
    ExpiresByType image/png "access plus 1 month" 
</IfModule> 

回答

0

你不能做到這一點的共享主機。共享主機的全部想法是,您共享同一臺機器,並將其IP地址與多個其他網站共享。除非您的主機提供商允許您「聲明」此IP地址(只有他們可以幫助您做),否則無法完成。如果可以這樣做,那也意味着所有分享你IP的其他網站所有者可以做你正在做的事情。服務器在哪裏重定向訪問者呢?

因爲這個原因,改變你的.htaccess文件根本無濟於事。由託管提供商管理的服務器配置否決了這一點。某些託管服務提供商允許選擇購買專用IP地址,或者通常如果您從其購買SSL證書,則會附帶一個。除此之外,你沒有選擇。