Reputation: 1726
I am required to remove .php extension and query string as well from url by rewriting the url I know this can be done in .htaccess file I have this in my .htaccess file so far
RewriteEngine on
DirectoryIndex Home.html
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) $1\.php [L]
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.html
RewriteRule .* Home.html
now the url example.com/blog.php?post=12&comment=3 can be accessed by example.com/blog.php/post/12/comment/3 but i want to remove .php extension as well this must be accessible through this url example.com/blog/post/13/comment/3
Any help?
Thank you in advance.
Upvotes: 1
Views: 3026
Reputation: 2797
Searches for everything except . after /
RewriteRule ^(([^/]+/)*[^.]+)$ /$1.php [L]
Upvotes: 1