0

I am working on XAMPP V.3.2.1 on Windows 8.1 64-bit.

I have the following code in my .htaccess file:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/?$ /?cmd=$1 [NC,L]

Now, when i write link like

http://localhost/aboutUs
http://localhost/MyAnyOtherPage

it works fine even if i use form in the page with post back method, but when i try to use links with two parameters and i change my .htaccess file link like this:

 RewriteEngine On
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule ^(.+)/?$ /?cmd=$1&caseSno=$2 [NC,L]

In this way i am accessing my page by cmd and searching database record with caseSno parameters.

To achieve this how can i write my hard coded links to run my page with searching database tables and pitch records with second parameter caseSno? This is not working for me:

My Original link is :

localhost/?cmd=caseDetailsByCaseSno&caseSno=2308

How to write this? The following is not working for me?

http://localhost/caseInformation/case/234

Thanks in advance

Abdul Rahman
  • 1,669
  • 4
  • 24
  • 39
  • For the two parameters, what part of the clean URL should be in the rewrite/query string? – Panama Jack Feb 11 '14 at 05:07
  • i want to use the page name in query string i don't want to display case number or anything else. – Abdul Rahman Feb 11 '14 at 05:23
  • Please give an example of exactly how the URL is supposed to look like with two parameters. – Panama Jack Feb 11 '14 at 05:24
  • I want to use URL like this: localhost/caseDetailsByCaseSno/234 which means that caseDetailsByCaseSno is the name of the page where 234 is the number i need to search within the databse table – Abdul Rahman Feb 11 '14 at 05:33

1 Answers1

1

This should help you with two parameters.

If you have this URL http://localhost/caseDetailsByCaseSno/234 then you should be able to use this htaccess.

 RewriteEngine On
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule ^([^/]+)/([^/]+)/?$ /?cmd=$1&caseSno=$2 [NC,L]

 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule ^(.+)/?$ /?cmd=$1 [NC,L]
Panama Jack
  • 24,158
  • 10
  • 63
  • 95
  • After changing my RewriteRule to yours, it does not work than – Abdul Rahman Feb 11 '14 at 05:24
  • Please give an example of exactly how the URL is supposed to look like with two parameters. – Panama Jack Feb 11 '14 at 05:26
  • I want to use URL like this: http://localhost/caseDetailsByCaseSno/234 which means that caseDetailsByCaseSno is the name of the page where 234 is the number i need to search within the databse table – Abdul Rahman Feb 11 '14 at 05:29
  • It is working fine now but the problem is now that it is not displaying the .css file. should i need to change the css file path in the main template page. i.e. the existing link is = how should i change the path of the css file here? – Abdul Rahman Feb 11 '14 at 05:52
  • Use absolute paths or include the `/` with JS and CSS when doing rewrites so do this. `href="/bootstrap/css/bootstrap.min.css"` Notice I added a backslash in front of bootstrap. – Panama Jack Feb 11 '14 at 05:59