0

How to remove php extension my url and question marks replace with slashes

http://eeroju.in/telugu/post.php?post_id=348 

to

http://eeroju.in/telugu/post/post_id/348 

I am using below code

        RewriteEngine On

        # Unless directory, remove trailing slash
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^([^/]+)/$ http://localhost/telugu/$1 [R=301,L]

        # Redirect external .php requests to extensionless url
        RewriteCond %{THE_REQUEST} ^(.+)\.php([#?][^\ ]*)?\ HTTP/
        RewriteRule ^(.+)\.php$ http://localhost/telugu/$1 [R=301,L]

        # Resolve .php file for extensionless php urls
        RewriteRule ^([^/.]+)$ $1.php [L]
        ---
        <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteBase /
        RewriteRule ^route-page\.php$ - [L]
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule . /route-page.php [L]
        </IfModule>
Naveed Ramzan
  • 3,565
  • 3
  • 25
  • 30
neeraja
  • 19
  • 1
  • 4

2 Answers2

2

include this in your .htaccess code **

 Options +Indexes +MultiViews

** in your html code, to link to another page do this

<a href="next-page">Click here</a> to go to next page

next-page is an .php file, but can be rendered to on the browser without the .php extension.

Lekens
  • 1,823
  • 17
  • 31
  • I don't think this answers the question - the main problem is how to get PHP files to be run by PHP without the `.php` extension. It requires an Apache configuration change. – halfer May 19 '17 at 21:16
0

Try to add following settings

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^.]+)$ $1.php [NC,L]
Med Dhiia
  • 64
  • 4