Php 如何从URL提交和获取IP地址?

Php 如何从URL提交和获取IP地址?,php,url,ip,Php,Url,Ip,我想进去 example.com/192.168.1.1 example.com/192.168.2.1:80 example.com/anotherexample.net example.com/yetanotheraxample.org:20 在浏览器地址栏中 如何从中获取IP地址和端口,而不显示404和403错误?我认为这可能适合您。 将其放入.htaccess文件中 <IfModule mod_rewrite.c> RewriteEngine On RewriteCond

我想进去

example.com/192.168.1.1
example.com/192.168.2.1:80
example.com/anotherexample.net
example.com/yetanotheraxample.org:20
在浏览器地址栏中


如何从中获取IP地址和端口,而不显示404和403错误?

我认为这可能适合您。 将其放入.htaccess文件中

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?$1 [L]
</IfModule>
结果:
在URL(example.com/192.168.1.1)中输入类似的内容后,变量$passedStr将在.htacessor example.com/?q=192.168.1.1中包含字符串“192.168.1.1”

mod rewrite。但是如果我在,我会嘲笑我的。不管发生什么,结肠都会导致这种情况。有没有办法用这种方法提取字符串?嗯。。有趣。看看我的测试脚本:这里只有我提到的.htaccess和一个php文件。你在运行linux Web服务器吗?我目前正在开发win/xamppYes,它是linux服务器。
$passedStr = $_SERVER['QUERY_STRING'];
echo $passedStr;