Php标题网址重定向和htacces

时间:2017-07-10 14:01:06

标签: php .htaccess header location

我对htaccess中的apache RewriteRule感到困惑。我的网络应用程序中有数百个header('Location: script_name.php');,并希望使网址更加用户友好(不支持搜索引擎优化,因为搜索引擎不允许抓取应用程序)。这是一段典型的代码:

if(isset($_POST['get_product']))
{
    // PHP/PDO code here
    header('Location: product_catalog_detail.php?with or without query strings');
} 

给出:

http://localhost/smart_entreprise/folder1/folder2/product_catalog_detail?catID=1&productID=1

现在我想保留此URL服务器端,并以product_catalog开头的所有脚本名称向用户显示:

http://localhost/smart_entreprise/folder1/folder2/catalog

甚至更好:

http://localhost/smart_entreprise/catalog

Doest有意义吗?感谢。

1 个答案:

答案 0 :(得分:0)

#/webroot/.htaccess
RewriteRule ^smart_entreprise\/(\w+)$ product_catalog_detail.php?catID=$1

请参阅

  1. https://codex.wordpress.org/htaccess
  2. https://www.digitalocean.com/community/tutorials/how-to-set-up-mod_rewrite-for-apache-on-ubuntu-14-04
相关问题