2

This question has an accepted answer at Stackoverflow


I have a PHP file named as otp.php.

When URL in the URL bar is

http://localhost/college/otp/MTA=/teacher

It should be treated as

http://localhost/college/otp.php?user=MTA=&role=teacher

For this, I created .htaccess file in http://localhost/college/:

RewriteEngine On    # Turn on the rewriting engine
RewriteCond %{HTTP_HOST} localhost  [NC]
RewriteRule    (.*otp)\/([A-Za-z0-9-]+=)\/([A-Za-z0-9-]+)  $1.php?user=$2&role=$3  [NC,L]

But, otp.php file says:

Notice: Undefined index: role in C:\wamp\www\college\otp.php on line 11

Notice: Undefined index: user in C:\wamp\www\college\otp.php on line 11

**See Image**


Created question here after this Comment.

Two Different Results:

paran
  • 31
  • 3
  • 2
    This question seems to have been closed too brashly - it's not a "duplicate" of the catch-all "mod_rewrite" question. There is no immediate problem with the mod_rewrite directive itself. The problem shown here looks like it is caused by a conflict with mod_negotiation/MultiViews (which is not covered at all by the linked question). – MrWhite May 14 '19 at 22:26
  • With the information provided in the question, I don't think any particular conclusions can be drawn as to the cause. One of the topics covered in the linked duplicate is debugging mod_rewrite rules, which is the best advice that can be offered, given the question's current state. – womble May 15 '19 at 00:58
  • I am unable to find the answer there... – paran May 16 '19 at 14:52

0 Answers0