English 中文(简体)
URl 中的空空空空间使用.htaccess在php 中不创建页面
原标题:empty space in url makes no pages in php using .htaccess

我无法使用 .htacess file 和 url 别名和 GET 方法检索值

.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;
}

下面是操作 我做了什么,

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..

感谢 谢谢

最佳回答

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.

问题回答

暂无回答




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签