0

I have a custom folder with number of php files. i want to create a friendly URL by removing .php from the URL.So i have created the .htaccess file in the custom folder where all the .php files located and written the below code but its is not working.

My URL is: magento/cl/unilever.php

Expected URL: magento/cl/unilever

.htaccess contains:

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^unilever $ unilver.php
Jonathon Reinhart
  • 132,704
  • 33
  • 254
  • 328
user2720197
  • 115
  • 1
  • 3
  • 9

1 Answers1

0

Assuming you want to rewrite just single directory, try this one:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(\w*)$ $1.php [L] 
George G
  • 7,443
  • 12
  • 45
  • 59
  • i have copied this code to .htaccess ,its not working – user2720197 May 06 '14 at 06:42
  • I've tested it, and it's working. Does `mod_rewrite` is enabled? Or it's just rewrite rules not working? – George G May 06 '14 at 06:44
  • Maybe because another `.htaccess` file is overriding, check if there are another redirections in parent directories, if so we'd do it differently – George G May 06 '14 at 06:51
  • There is no redirections in the parent directory. – user2720197 May 06 '14 at 06:57
  • So does it throws any error? or just it does nothing? – George G May 06 '14 at 06:59
  • its just throwing not found error when i try to access – user2720197 May 06 '14 at 07:01
  • OK please see this questions: http://stackoverflow.com/questions/9635524/remove-php-extensions-with-htaccess-without-breaking-directoryindex and this http://stackoverflow.com/questions/6509099/htaccess-no-extension-required if anyway you can't succeed you can skype me @garchagudashvili without '@' – George G May 06 '14 at 07:15