url中的空白将使php中没有使用.htaccess的页面
我在使用url中的空白将使php中没有使用.htaccess的页面,php,.htaccess,Php,.htaccess,我在使用.htacess文件和url别名以及GET方法检索值时遇到问题 .htaccess文件 以下是我所做的操作 URL 1 : www.example.com/search-location/london ouput : Location : london status : Good URL 2 : www.example.com/search-location/north-london output : Error 404 , Object not
.htacess
文件和url别名以及GET
方法检索值时遇到问题
.htaccess文件
以下是我所做的操作
URL 1 : www.example.com/search-location/london
ouput : Location : london
status : Good
URL 2 : www.example.com/search-location/north-london
output : Error 404 , Object not found!
Status : The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.
URL 3 : www.example.com/search-location/north%20london
output : Error 404 , Object not found!
Status : The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.
但是如果我给出一个,我无法得到那些get
方法loc
变量的值(空格)或-
(hypen)。
如何从url获取值
谢谢尝试将(\w+)
替换为(.*)
,它可以匹配任何内容,而不仅仅是一个单词。或者,如果您只需要字符和破折号(-),可以使用以下命令:([a-Za-z-]+)
还有一个帮助调试.htaccess的东西。isset($\u GET['loc'])或!空($\u GET['loc'])
没有意义。删除其中一个(我会将isset
删除为!empty
包括该检查)
if (isset($_GET['loc']) or !empty($_GET['loc'])) {
$d_location = $_GET['loc'];
echo "Location : " . $d_location;
}
URL 1 : www.example.com/search-location/london
ouput : Location : london
status : Good
URL 2 : www.example.com/search-location/north-london
output : Error 404 , Object not found!
Status : The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.
URL 3 : www.example.com/search-location/north%20london
output : Error 404 , Object not found!
Status : The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.