【发布时间】:2014-12-01 21:56:11
【问题描述】:
我可以知道如何检查域内用户的动态 url 可用性,以便他们可以创建自己的站点 url
我正在遵循的步骤: 1) 通过文本框,他们将能够写下他们的昵称/personal_identity 例如:说 Custom_Blog
2) 因此,对于指定用户,我的网站域将是 http://example.com/Custom_Blog/。
3)冲突:但我确实在 htaccess 中创建了一个选项卡“http://example.com/Custom_Blog”链接,用于编辑用户的博客详细页面。
所以,当用户在文本框中输入时,我需要验证 url 的可用性,无论该 url 是否已在使用中? 我尝试了这段没有帮助的代码,因为它正在为已经使用(存在)的 url 获取代码 302:
$handle = curl_init($url);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, TRUE);
/* Get the HTML or whatever is linked in $url. */
$response = curl_exec($handle);
/* Check for 404 (file not found). */
$httpCode = curl_getinfo($handle, CURLINFO_HTTP_CODE);
if($httpCode == 404 || $httpCode == 302) {
/* Handle 404 here. */
}
curl_close($handle);
【问题讨论】:
标签: php ajax .htaccess mod-rewrite curl