繁体   English   中英

php标头网址重定向和htacces

[英]Php header url redirect and htacces

我对htaccess中的Apache RewriteRule感到困惑。 我有数百个header('Location: script_name.php'); 在我的webapp中,并且希望使url更加用户友好(不支持SEO,因为不允许搜索引擎抓取该应用)。 这是一段典型的代码:

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

这样做有意义吗? 谢谢。

#/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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM