0
我试图通过.htaccess为我的网站设置重写规则。.htaccess通过IP地址访问时未找到rewriterule路径
http://www.example.com/admin/my/virtual/path
问题是,当我试图通过IP地址来访问,返回404页 - 当域名访问像它工作正常。
我将IP与我的虚拟路径原因绑定,当我访问http://192.168.1.2/时,它显示http://www.example.com/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>
我几乎可以肯定它与虚拟主机有关,而不是mod_rewrite。你的虚拟主机的内容是什么? – Dekel
它与vhost无关,因为我可以通过http://192.168.1.2/访问我的索引页,也可以通过http://www.example.com/ –
查看服务器上的日志吗? – Dekel