apache - htaccess rewrite remove php extension on subdirectory -


my htaccess file under folder:

http://localhost/project/folder/
|
|--- change this:
|
|_ http://localhost/project/folder/about.php
|____ http://localhost/project/folder/about
|____ http://localhost/project/folder/about/
|
|_ http://localhost/project/folder/anything.php
|____ http://localhost/project/folder/anything
|____ http://localhost/project/folder/anything/
|
|_ http://localhost/project/folder/file.php?id=8888
|____ http://localhost/project/folder/file/id/8888
|____ http://localhost/project/folder/file/id/8888/
|
|_ http://localhost/project/folder/file.php?edit=8888
|____ http://localhost/project/folder/file/edit/8888
|____ http://localhost/project/folder/file/edit/8888/

what code found until now:

options +followsymlinks -multiviews rewriteengine on  rewriterule file/edit/(.*)/ file.php?edit=$1 rewriterule file/edit/(.*) file.php?edit=$1   rewriterule file/id/(.*)/ file.php?id=$1 rewriterule file/id/(.*) file.php?id=$1   # remove file extension rewritecond %{request_filename} !-f rewritecond %{request_filename}.php -f rewriterule ^(.*)$ $1.php [nc,l] 

problem facing: if try, http://localhost/project/folder/about working, not http://localhost/project/folder/about/.

you can use .htaccess:

options +followsymlinks -multiviews rewriteengine on  rewritecond %{the_request} \s/+(.+?)\.php\?([^=]+)=([^\s&]+) [nc] rewriterule ^ /%1/%2/%3? [r=302,l,ne]  rewritecond %{the_request} \s/+(.+?)\.php\s [nc] rewriterule ^ /%1 [r=302,l,ne]  rewritecond %{request_filename} -f [or] rewritecond %{request_filename} -d rewriterule ^ - [l]  rewriterule ^file/edit/([^/]+)/?$ file.php?edit=$1  [l,qsa,nc]  rewriterule ^file/id/([^/]+)/?$ file.php?id=$1 [l,qsa,nc]  # remove file extension rewritecond %{request_filename}.php -f rewriterule ^(.+?)/?$ $1.php [l] 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -