0

Having the below urls, but only the first one works with my htaccess code. Please help to fix this for both url at time. Thank you.

URL 1: http://domain.com/index.php?id=Apple

Output : http://domain.com/Apple (This is ok)

URL 2: http://domain.com/index.php?id=Apple-Board&jid=Chief-Accountant

Output : http://domain.com/Apple-Board (This is not ok)

Expected Output : http://domain.com/Apple-Board/Chief-Accountant

Options -Multiviews RewriteEngine on RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+index\.php\?id=([^\s&]+) [NC] RewriteRule ^ /%1? [R=302,L] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-l RewriteRule ^([^/]+)/?$ index.php?id=$1 [B,L] RewriteRule /id/(.*)/jobid/(.*)/ index.php?id=$1&jid=$2 

1 Answer 1

1

You can use:

Options -Multiviews RewriteEngine on RewriteCond %{THE_REQUEST} \s/+index\.php\?id=([^\s&]+)&jid=([^\s&]+) [NC] RewriteRule ^ /%1/%2? [R=302,L] RewriteCond %{THE_REQUEST} \s/+index\.php\?id=([^\s&]+) [NC] RewriteRule ^ /%1? [R=302,L] RewriteCond %{REQUEST_FILENAME} -d [OR] RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -l RewriteRule ^ - [L] RewriteRule ^([^/]+)/?$ index.php?id=$1 [QSA,L] RewriteRule ^([^/]+)/([^/]+)/?$ index.php?id=$1&jid=$2 [L,QSA] 
Sign up to request clarification or add additional context in comments.

2 Comments

Hi anubhava, Thank you for your quick response. But Still it is not working. (URL 2: domain.com/index.php?id=Apple-Board&jid=Chief-Accountant Output : domain.com/Apple-Board (This is not ok) Expected Output : domain.com/Apple-Board/Chief-Accountant)
Thaks a lot anubhava. I am near to the output, need to work on php code for some fix. Thanks again.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.