Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
url中的空白将使php中没有使用.htaccess的页面_Php_.htaccess - Fatal编程技术网

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.