skip to Main Content

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:

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:

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?

2

Answers


  1. Your regex is not matching date part correctly and you must remove leading / from target as you’re using a RewriteBase.

    Options -Indexes
    RewriteEngine on
    RewriteBase /reports/causelist/
    
    RewriteRule ^(d+)/([d-]+)/(.+?)/?$ final_causelist.php?wb_sno=$1&dated=$2&j_names=$3 [L,QSA]
    
    Login or Signup to reply.
  2. 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]
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search