我在使用.htacess
文件和 url 别名以及GET
检索值的方法时遇到问题
.htaccess 文件
<IfModule mod_rewrite.c>
# Enable Rewriting
RewriteEngine on
RewriteRule ^search-location/(\w+)/?$ findjob4.php?loc=$1
</IfModule>
findjob.php 文件
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.
但是,如果我在 url 值之间给出(空格)或(hypen),我无法获得这些GET
方法loc
变量的值。我如何从网址中获取值... .
-
谢谢