[英]Remove directory name from URL using htaccess but keep parent page
[英].htaccess to pass parameters and remove the page name
我的網站中有以下文件夾結構:
example.com/
reports/
causelist/
final_causelist.php
我有一個指向 final_causelist.php 頁面的鏈接/URL,如下所示:
http://example.com/reports/causelist/final_causelist.php?wb_sno=23&dated=2020-10-26&j_names=Mr.+ABC
我想訪問如下頁面:
http://example.com/23/2020-10-26/Mr.+ABC
對於上述內容,我使用以下代碼在原因列表文件夾中創建了.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]
但是它不顯示頁面並抱怨在此服務器上找不到請求頁面?
您的正則表達式與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]
你能不能試試以下。
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.