简体   繁体   English

.htaccess 传递参数并删除页面名称

[英].htaccess to pass parameters and remove the page name

I have the following folder structure in my website:我的网站中有以下文件夹结构:

     example.com/
                reports/
                        causelist/
                                 final_causelist.php

I have a link / URL to the final_causelist.php page is as:我有一个指向 final_causelist.php 页面的链接/URL,如下所示:

http://example.com/reports/causelist/final_causelist.php?wb_sno=23&dated=2020-10-26&j_names=Mr.+ABC

I want to access the page like the following:我想访问如下页面:

http://example.com/23/2020-10-26/Mr.+ABC

For the above, I created .htaccess in the causelist folder with the following code:对于上述内容,我使用以下代码在原因列表文件夹中创建了.htaccess

RewriteEngine on  
RewriteBase /reports/causelist/
Options -Indexes

RewriteRule ^(\d+)/([a-z-]+)/(.+)/$ /final_causelist.php?wb_sno=$1&dated=$2&j_names=$3 [L,B]

But it does not show the page and complaint that the requesting page is not found on this server?但是它不显示页面并抱怨在此服务器上找不到请求页面?

Your regex is not matching date part correctly and you must remove leading / from target as you're using a RewriteBase .您的正则表达式与date部分不正确匹配,您必须在使用RewriteBase从目标中删除前导/

Options -Indexes
RewriteEngine on
RewriteBase /reports/causelist/

RewriteRule ^(\d+)/([\d-]+)/(.+?)/?$ final_causelist.php?wb_sno=$1&dated=$2&j_names=$3 [L,QSA]

Could you please try following.你能不能试试以下。

RewriteEngine on
RewriteCond %{REQUEST_URI} ^/(\d+)/(\d{4}-\d{2}-\d{2})/(.+?)/?$
RewriteRule ^.*$ /reports/causelist/final_causelist.php?wb_sno=%1&dated=%2&j_names=%3 [QSA,NE,NC,L]

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

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