skip to Main Content

There is something strange going on lately.
The following htaccess redirect / url rewriting code worked perfectly fine for a month. But started giving error code 500 today.
I asked my hosting provider he said that he migrated all the code to a new server. I don’t understand why its not working now. The same code worked fine for almost a month.

What i want to achieve :

www.example.com/22     ---should go to-->     www.example.com/view.php?iid=22

Code :

RewriteEngine on
RewriteRule ^([0-9]+) view.php?iid=$1 [NC, L]

PHP version : 7.2

2

Answers


  1. Chosen as BEST ANSWER

    I don't know how but the issue got fixed by removing NC from [NC, L]

    New code looks like this :

    RewriteRule ^([0-9]+)$   view.php?iid=$1 [L]
    

  2. Replace your rule with this:

    RewriteRule ^(d+)/?$ view.php?iid=$1 [QSA,L]
    

    That is:

    Use anchor $ to match only digits in URI and no spaces in side the flags [...]

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search