这个URL给了我两个主要的参数,文件夹和页面,以及其他可以变量是否存在的参数。
另一个参数是给定URL的多个参数。
如何向用户显示第一个URL并在PHP-2应用程序中使用第二个URL?使用htaccess rewrithe是正确的吗?
我已经在网上搜索过了,但没有找到解决方案。
发布于 2015-12-25 20:29:12
我认为您不能仅仅通过.htaccess来完成它,因为参数的可变计数。
添加.htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]此规则将将所有404请求传递给index.php,并在index.php解析url中传递。
$parts = explode('/', trim($_SERVER['REQUEST_URI'], '/'));
$folder = $parts[0];
$page = $parts[1];
$otherparm1 = $parts[2];
$otherparm2 = $parts[3];发布于 2015-12-25 20:28:23
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ master.php?folder=$1&page=$2&something=$3[...] [L,QSA]
</IfModule>然后,您可以像href那样链接页面:
<a href="http://www.domain.com/adm/folder/page/somthing/somthing/somthing[...]">Link</a>https://stackoverflow.com/questions/34466103
复制相似问题