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> 
0

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

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.
0

Try to add following settings

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.