0

I am using wamp server which consists of my project folder testCase which consists of few php files

testCase
  - view.php
  - add.php
  - delete.php
  - .htaccess

In the .htaccess file I have code like

RewriteEngine on
RewriteRule ^view?$ view.php

I am trying to run my project with url as "localhost/testCase/view" rather than "localhost/testCase/view.php" which results as Not found

I have found many tutorials regarding this htaccess in stackoverflow. Since I am a very beginner to programming, I could not fix this issue. Can anybody please help me. Even I get down vote or duplicate question I am eager to fix my issue.

Thank you.

shyam
  • 1
  • 3

1 Answers1

0

You want to remove .php extension,

Try below rule,

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

Above will work for all your php files in testcase directory.

Abhishek Gurjar
  • 7,152
  • 9
  • 35
  • 40
  • Yes i copy paste your rules in my htaccess file inside the testCase directory but I get page not found – shyam Feb 22 '17 at 05:33
  • Mmhhhh Please check your error log and httpd.conf if you have mod_rewrite enabled or not because it is working here. – Abhishek Gurjar Feb 22 '17 at 05:35
  • mod_rewrite means inside apache/conf/httpd.conf ? there mod_rewrite is enabled Error: GET http://localhost/testCase/view404 (Not Found) – shyam Feb 22 '17 at 05:41
  • Please also check these two conditions [1](http://stackoverflow.com/questions/869092/how-to-enable-mod-rewrite-for-apache-2-2) & [2](http://stackoverflow.com/questions/18740419/how-to-set-allowoverride-all) – Abhishek Gurjar Feb 22 '17 at 05:44