I have a problem working with .htacess file and url aliasing and GET method to retrieve values
.htaccess file
<IfModule mod_rewrite.c>
# Enable Rewriting
RewriteEngine on
RewriteRule ^search-location/(\w+)/?$ findjob4.php?loc=$1
</IfModule>
findjob.php file
if (isset($_GET['loc']) or !empty($_GET['loc'])) {
$d_location = $_GET['loc'];
echo "Location : " . $d_location;
}
below are the operations what i did,
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.
But i could not get the values of those GET method loc variables, if i give a . . (space) or - (hypen) between url values.
how do i get the values from the url..
thanks
Try replacing the
(\w+)with(.*)which matches anything instead of just a word. Or if you want just characters and a dash (-) you can use this:([A-Za-z-]+)Also there’s this tool that helps debugging .htaccess stuff.