0

I have a website, that i wrote by hand, no CMS, just for learning purposes. A while ago I rewrote my website using more of php and renamed the .html files to .php.

Ages ago I edited the .htaccess added some code that i got online. And what it did was, it doesn't use a tutorials/article.html or tutorials/article.phpbut no extensions at all: tutorials/article

I found that allot of websites that linked to my articles are still using the .html extension.

My question is how do I redirect all the links going to .php and .html to no extensions at all?

Also: I have social haring buttons on my website, does the redirect to no extensions at all, mean that all the +1, likes, tweets and linkedin are no more?

2
  • Can you show us the rules you already have that you're using for extension less URLs. Commented Nov 12, 2014 at 14:31
  • @anubhava, unfortunately, not at this time(Work, bills, HALO) tonight or tomorrow. Commented Nov 12, 2014 at 14:48

2 Answers 2

1

Add the following to your htaccess. It will remove the .html

RewriteRule ^([^\.]+)$ $1.html [NC,L] 

Source: http://alexcican.com/post/how-to-remove-php-html-htm-extensions-with-htaccess/

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

Comments

0

Do this with htaccess

Something like below, for both url with .php & html extention

RewriteCond %{THE_REQUEST} \ /+([^\?\ ]+)\.(php|html?)
RewriteRule ^ /%1 [L,R=301]

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.