Abdul Rahman
Abdul Rahman

Reputation: 1705

URL Re-Writing with .htaccess in custom php (xampp) on windows 10

I want to re-write the following url from:

www.phcc.com/reports/caseFullDtlByCaseSno.php?case_sno=1

  To

http://www.phcc.com/reports/1/caseFullDtlByCaseSno.html

For this i have written the following .htaccess file inside the reports directory which is the sub-directory of the website root:

RewriteEngine on  
RewriteBase /reports/

RewriteRule ^(.*)/(\d+)\.php $1=case_sno&$2.html [NL,L]  
RewriteRule ^(.*)/(\d+)\.html $1=case_sno&$2.php [L]

but it does not complete the request as i need it. What should i do?

Upvotes: 1

Views: 74

Answers (1)

Abhishek Gurjar
Abhishek Gurjar

Reputation: 7476

Try with below, I am assuming the html files are not existent.

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([\d]+)/([\w-]+)\.html$ $2.php?case_sno=$1 [L]

Upvotes: 1

Related Questions