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

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

android - How to create dynamically Fragment pager adapter -

1111. appearing after print sequence - php -