1

I have the following htaccess file code below

RewriteEngine On
RewriteBase /site/public/admin/

RewriteCond %{REQUEST_METHOD} POST
RewriteRule ^ - [L]

RewriteCond %{THE_REQUEST} \s([^.]+?)(?:\.php)?\?caseid=([^&\s]+) [NC]
RewriteRule ^ %1/caseid/%2/? [R=302,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/caseid/([^/]+)/?$ $1.php?caseid=$2 [L,NC,QSA]

## hide .php extension snippet    
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1/ [R=302,L]

# add a trailing slash
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule [^/]$ %{REQUEST_URI}/ [L,R=301]

# To internally forward /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+?)/?$ $1.php [L]

This works perfectly fine as long as I provide 1 parameter which is caseid i.e

http://localhost/site/public/admin/PIClaimant.php?caseid=11

The URL above successfully changes to

http://localhost/site/public/admin/PIClaimant/caseid/11/

I've had a few pages with two parameters, which are PIClaimant.php?caseid=11&picid=34. Initially when I was creating htaccess file I did not pay attention to those pages (&picid=34 only being used at a few pages 4 or 5 max). Now when I go back to those pages which has those parameters, they are not working not showing the content of page. They work till first parameter PIClaimant/caseid/11/ but not with the second parameter.

Since I am not very good at this (mode rewriting) I need your help.

Any Ideas?

1
  • @anubhava are you there? Commented Jul 30, 2014 at 12:14

2 Answers 2

2

Things are getting more complicated now :)

Try this code in your .htaccess:

RewriteEngine On
RewriteBase /site/public/admin/

RewriteCond %{REQUEST_METHOD} POST
RewriteRule ^ - [L]

RewriteCond %{THE_REQUEST} \s([^.]+?)(?:\.php)?\?caseid=([^&\s]+)?\&picid=([^&\s]+)\s [NC]
RewriteRule ^ %1/caseid/%2/picid/%3/? [R=302,L,NE]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/caseid/([^/]+)/picid/([^/]+)/?$ $1.php?caseid=$2&picid=$3 [L,NC,QSA]

RewriteCond %{THE_REQUEST} \s([^.]+?)(?:\.php)?\?caseid=([^&\s]+)\s [NC]
RewriteRule ^ %1/caseid/%2/? [R=302,L,NE]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/caseid/([^/]+)/?$ $1.php?caseid=$2 [L,NC,QSA]

## hide .php extension snippet    
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} \s([^.]+)\.php [NC]
RewriteRule ^ %1/ [R=302,L,NE]

# add a trailing slash
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule [^/]$ %{REQUEST_URI}/ [L,R=301,NE]

# To internally forward /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+?)/?$ $1.php [L]
Sign up to request clarification or add additional context in comments.

8 Comments

thank you @anubhava it works fine i'm happy but can I add one thing here at the moment it is showing like this(http://localhost/site/public/admin/PIClaimant/caseid/8/43/) is there any way I can have to add picid before 43 ie. (http://localhost/site/public/admin/PIClaimant/caseid/8/picid/43/)
I'm really grateful of yours thanks for taking time out and helping me
no it does not work it work its behaves weirdly like works with the very last record of that case.. but not with the rest... its like if one case has more than one picid's It would work with last one only
Can you provide URLs for which it doesn't work. I will check on your comment in an hour as I need to rush to a meeting.
no problem the working url (http://localhost/site/public/admin/PIClaimant/caseid/8/picid/43/') when I click other pic's it shows like this (localhost/site/public/admin/PIClaimant/caseid/8/picid/28/caseid/…`)
|
1

Change your code to the code below:

RewriteEngine On
RewriteBase /site/public/admin/

RewriteCond %{REQUEST_METHOD} POST
RewriteRule ^ - [L]

#RewriteCond %{THE_REQUEST} \s([^.]+?)(?:\.php)?\?caseid=([^&\s]+) [NC]
RewriteCond %{THE_REQUEST} \s([^.]+?)(?:\.php)?\?caseid=([^&\s]+)?\&picid=([^&\s]+) [NC]
RewriteRule ^ %1/caseid/%2/picid/%3/? [R=302,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule ^([^/]+)/caseid/([^/]+)/?$ $1.php?caseid=$2
RewriteRule ^([^/]+)/caseid/([^/]+)/?$ $1.php?caseid=$2&picid=$3 [L,NC,QSA]


## hide .php extension snippet    
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1/ [R=302,L]

# add a trailing slash
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule [^/]$ %{REQUEST_URI}/ [L,R=301]

# To internally forward /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+?)/?$ $1.php [L]

replace the code with your code see if that works

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.