0

I have url example.com/lt.php/example and want remove .php that will be example.com/lt/example
I try with htacces, but I think that's impossible

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/$ http://moliplante.com/folder/$1 [R=301,L]

RewriteCond %{THE_REQUEST} ^(.+)\.php([#?][^\ ]*)?\ HTTP/
RewriteRule ^(.+)\.php$ http://example.com/folder/$1 [R=301,L]

RewriteRule ^([^/.]+)$ $1.php [L]
Wizard
  • 10,985
  • 38
  • 91
  • 165
  • i think there is a similar question on it http://stackoverflow.com/questions/9821222/remove-php-extension-explicitly-written-for-friendly-url – Jianhong Jul 24 '13 at 14:38

2 Answers2

2

This might work:

 RewriteRule ^(.+)\.php/(.+)$ $1/$2

The first backreference would capture lt from lt.php and the second backreference would have example and php would be added to it.

  • i made an edit...it just appended .php to the end of the second backreference – akash.trivedi Jul 24 '13 at 15:02
  • 1
    @TomasLietuva This does work. If you need it to redirect, just add the `[R]` flag. If you want `example.com/lt/example` to actually execute `example.com/lt.php/example` internally (or probably more something like `example.com/lt.php?key=example`) then you should add that to your question. – Sumurai8 Jul 25 '13 at 10:55
0

Try this, hope it will work

RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}\.php -f 
RewriteRule ^(.*)$ $1.php
alright
  • 59
  • 6