2016-11-09 14 views
0

.htaccessで自分のウェブサイトの書き換えルールを設定しようとしています。.htaccess rewriterule IPアドレスを使用してアクセスしているときにパスが見つかりません

http://www.example.com/admin/my/virtual/path

問題私はIPアドレスを介してアクセスしようとしたとき、それは404ページを返している - などのドメイン名によるアクセスがとき、それは正常に動作します。

http://192.168.1.2/にアクセスしたときに私の仮想パスにIPがバインドされています。http://www.example.com/admin/というページ、つまりadminのホームページが問題なく表示されます。

次のリンクは機能と404ページ返されていません -

http://192.168.1.2/my/virtual/path

が、私はその.htaccessの問題を推測します。ここに私の.htaccessコードはFYI

RewriteEngine On 
RewriteCond %{HTTPS} off 
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] 
# The following rule tells Apache that if the requested filename 
# exists, simply serve it. 
RewriteCond %{REQUEST_FILENAME} -s [OR] 
RewriteCond %{REQUEST_FILENAME} -l [OR] 
RewriteCond %{REQUEST_FILENAME} -d 
RewriteRule^index.php [L] 
# The following rewrites all other queries to index.php. The 
# condition ensures that if you are using Apache aliases to do 
# mass virtual hosting, the base path will be prepended to 
# allow proper resolution of the index.php file; it will work 
# in non-aliased environments as well, providing a safe, one-size 
# fits all solution. 
RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$ 
RewriteRule ^(.*) - [E=BASE:%1] 
RewriteRule ^([^?]*)$ %{ENV:BASE}index.php [NC,L] 

です。ここIPのための私のバーチャルホストの設定されて -

<VirtualHost xxx.xxx.xxx.xxx:80> 
    DocumentRoot /path/of/my/hosting/location/public_html/admin 
    <Directory "/path/of/my/hosting/location/public_html/admin"> 
     allow from all 
     Options None 
     Require all granted 
    </Directory> 
</VirtualHost> 

ここでは、一部をホストし、私のドメインである -

<VirtualHost example.com:80> 
    DocumentRoot /path/of/my/hosting/location/public_html 
    <Directory "/path/of/my/hosting/location/public_html"> 
     allow from all 
     Options +FollowSymLinks 
     allowoverride all 
     Require all granted 
     HostNameLookups on 
    </Directory> 
    ServerName example.com 
    ServerAlias www.example.com 
</VirtualHost> 
+0

私はほとんどそれが仮想ホストではなく、mod_rewriteに関連していると確信しています。あなたの幽霊の内容は何ですか? – Dekel

+0

それは関連する仮想ホストではないため、私はインデックスページにhttp://192.168.1.2/でアクセスできますし、http://www.example.com/ –

+0

を経由してサーバーにログをチェックしましたか? – Dekel

答えて

1

ドメインのバーチャルホスト部分がありallowoverride all内部では、変更を許可するようにApacheに指示します。.htaccessしかし、ipのvhost部分にはそれがありません。

allowoverride allip vhost-blockに追加してください。これは問題ありません。

<VirtualHost xxx.xxx.xxx.xxx:80> 
    DocumentRoot /path/of/my/hosting/location/public_html/admin 
    <Directory "/path/of/my/hosting/location/public_html/admin"> 
     allowoverride all 
     allow from all 
     Options None 
     Require all granted 
    </Directory> 
</VirtualHost> 
関連する問題