【发布时间】:2015-08-28 17:16:33
【问题描述】:
我有类似的动态网址
http://epathasala.com/schooldetails.php?name=john-paul-higher-secondary-school
http://epathasala.com/universitydetails.php?name=demo-university
http://epathasala.com/schooldetails.php?name=tagore-international-school
我需要删除所有查询字符串并更改如下网址
http://epathasala.com/collegedetails/gtn-arts-college http://epathasala.com/universitydetails/demo-university http://epathasala.com/schooldetails/tagore-international-school我已尝试 [Pretty URL - mod_rewrite question][1] 但无法正常工作。请有人帮忙。谢谢
我已经在 htaccess 代码下面尝试过,但它不起作用。
RewriteEngine On
RewriteBase /
RewriteRule ^epathasala/schooldetails/(.*)$ /epathasala/schooldetails.php?name=$1 [NC,L]
我需要从 url 中删除这部分 ".php?name="。
【问题讨论】:
-
$_SERVER['PHP_SELF']将完成这项工作。编辑:或者您需要在.htaccess中使用它吗? -
谢谢。我想使用 .htaccess
-
您可以使用mod_rewrite 模块(请参阅
RewriteEngine和RewriteCond/RewriteRule)。 -
是的,我只用过那个,请看问题,我更新了
-
This 会做到的。
标签: php .htaccess mod-rewrite