removing .html or .PHP URL extension using .htaccess not working -


can me remove .html or .php extension in url.

i trying below code in php project, not working. have tried many .htaccess codes, nothing helps me..

rewriteengine on  rewritecond %{request_filename} !-d rewritecond %{request_filename}\.html -f rewriterule ^([^/]+)/$ $1.php 

thanks in advance

previously faced problem removing .html or .php extension form url.

i have solution here

options +followsymlinks -multiviews # turn mod_rewrite on rewriteengine on rewritebase /  ## hide .php extension # externally redirect /dir/foo.php /dir/foo rewritecond %{the_request} ^[a-z]{3,}\s([^.]+)\.php [nc] rewriterule ^ %1 [r,l,nc]  ## internally redirect /dir/foo /dir/foo.php rewritecond %{request_filename}.php -f rewriterule ^ %{request_uri}.php [l] 

put above code in .htaccess file, above code .php files. .html files go through below code

options +followsymlinks -multiviews # turn mod_rewrite on rewriteengine on rewritebase /  ## hide .php extension # externally redirect /dir/foo.html /dir/foo rewritecond %{the_request} ^[a-z]{3,}\s([^.]+)\.html [nc] rewriterule ^ %1 [r,l,nc]  ## internally redirect /dir/foo /dir/foo.html rewritecond %{request_filename}.html -f rewriterule ^ %{request_uri}.html [l] 

i replaced .php .html

hope helps you.. :)


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -