InMotion Hosting Support Center

Lately there seems to be a trend where designers want to cloak their file extensions from their visitors. For example, they want the URL 'domain.com/index.html' to display as 'domain.com/index' for whatever reason. Some like the way it looks, others believe it helps with SEO, and others believe it is better for security. I am unsure the last two hold any bit of truth, however. This is a feature you can implement via your htaccess file. This article will guide you through doing so via your cPanel.

How to remove file extensions from display via htaccess

  1. Log into your cPanel
  2. Find the Files category and click on the File Manager icon.
    cpanel
  3. A popup box will appear. For the primary domain, click on the Web Root radio button. For addon domains, click on the dropdown and find your desired addon domain name. Be sure the checkbox next to Show Hidden Files is checked. Click the Go button to enter the File Manager.
    file-manager-show-hidden
  4. You should now be in the root folder of the domain you chose. Look for the .htaccess file and right click on it. This brings up a menu. Find and click on the Edit option. If you get a popup box, simply find and click the Edit button in the lower right corner to continue to the editor.
    file-manager-htaccess
  5. You are now in the text editor. As most sites are coded with either htm or php, we have include the code for both below.
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}\.php -f
    RewriteRule ^(.*)$ $1.php

    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}\.html -f
    RewriteRule ^(.*)$ $1.html
  6. Be sure to hit the Save Changes button in the upper right corner to save your new htaccess configuration. Your site should now display the address without the file extension.

Support Center Login

Social Media Login

   
Social Login Joomla

Related Questions

Here are a few questions related to this article that our customers have asked:
Ooops! It looks like there are no questions about this page.
Would you like to ask a question about this page? If so, click the button below!
Ask a Question
n/a Points
2014-04-26 1:13 pm
using this code i am not able to remove the extension from my code..
Staff
28,434 Points
2014-04-28 12:12 am
Hello Vijay,

We would be happy to assist you. Would you please reply with the code you have in your .htaccess so we can take a look?

Kindest Regards,
Scott M
n/a Points
2014-06-13 3:08 pm

dear sir there is a code utf-8  and page showing empity

 

thanks

n/a Points
2014-05-02 5:46 am

Hi Vijay, you're probably referring to a linked page if you're still seeing the file extension. Make sure you're links don't have .html or .php at the end of them:

<a href="/support/linkedpage.php">link text</a> is wrong, it will force the browser to display .php despite the rewrite engine in use.

<a href="/support/linkedpage">link text</a> is right, this will ask the browser to find this file, and with the rewrite engine it will find it and display it without the extension.

n/a Points
2015-02-15 3:21 am

Thank you so much! c: This is very helpful. I followed the instructions above and your help instructions to the other dude. 

n/a Points
2014-07-11 7:08 pm

Hi there! A .htaccess file was not in my file manager, even after making sure I would be able to see hidden files, so I had to create one on my own. I am trying to remove extensions from my website using the two codes listed above (for .html and .php) and it is not working. This is the code I have:

 

Options +FollowSymLinks

Options +Indexes

RewriteEngine on

RewriteCond %{SCRIPT_FILENAME} !-d

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

 

RewriteEngine on 

RewriteCond %{REQUEST_FILENAME} !-d 

RewriteCond %{REQUEST_FILENAME}\.html -f 

RewriteRule ^(.*)$ $1.html

Staff
25,386 Points
2014-07-11 7:32 pm
Hello Brenna,

Sorry for the problems with the .htaccess file. In reviewing the code you provided, it does not match what was provided in the article above. Please go back and edit your .htaccess file so that it matches what Scott has provided for the re-write rules and it should work.

If you continue to have problems, please let us know.

Regards,
Arnel C.
n/a Points
2014-11-27 8:05 am

this code only run on localhost. but not working in live. so pls tell about. and fix solutions. 

 

Thanks

Staff
17,092 Points
2014-11-28 1:30 pm
Hello Manish,

Thank you for contacting us. What Arnel is suggesting is that you use the syntax provide in the article above for the .htaccess rules.

This code has already been tested successfully, and works well.

Thank you,
John-Paul

Thank you
n/a Points
2014-07-11 9:00 pm

I have edited my .htaccess file with the code above and it still does not work.

Staff
25,386 Points
2014-07-11 9:06 pm
Brenna,

Apologies for the problem with the .htaccess. However, without any information on your website, it makes it difficult for us to help troubleshoot the problem. Can you please provide a URL and a description of how we duplicate the problem you're seeing?

Kindest regards,
Arnel C.
n/a Points
2014-07-11 10:15 pm

The url that is working is creamilla.com/brenna.php, however, when you type in creamilla.com/brenna, you get a not found error. The complete code in my .htaccess is:

<Files .htaccess>order allow,deny deny from all </Files> 

suPHP_ConfigPath /home/creamilla/public_html 

RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php

RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.html -f RewriteRule ^(.*)$ $1.html

Thank you.

Staff
28,434 Points
2014-07-13 1:33 pm
Hello Brenna,

Yes, that is correct, you will get a not found error. This is because the server needs to know what you are looking for specifically. Despite not showing the .php in the address bar, the file is still named brenna.php, there could also be brenna.htm and brenna.html file names, all being told not to display their extension. The server needs to know which one you want. In fact, if you do not put an extension at all, the server assumes you are looking for a subfolder named brenna. When visiting the site, either by code or typing directly, you must be specific. The removal of the extension is simply for aesthetics.

Kindest Regards,
Scott M
n/a Points
2014-07-13 3:23 pm

Oh, that makes sense. Sorry, I'm a complete newbie. What about for links? Is there any way I can direct from /brenna.php to just /brenna? I tried putting /brenna for a link and it displayed the not found error as well.

Staff
28,434 Points
2014-07-13 9:27 pm
Hello Brenna,

As far as the code for the link, you need to be specific (brenna.php, brenna.htm, etc) because the server is not so smart. The code in the .htaccess file should still take over and display it as example.com/brenna however so your visitors will never know the extension.

Kindest Regards,
Scott M
n/a Points
2014-07-13 10:26 pm

I put the .php at the end of the address in the link, however when I check it, it still goes to /brenna.php.

Staff
11,186 Points
2014-07-14 10:13 am
You may have old data cached in your browser. Try clearing your browser cache.
n/a Points
2014-07-14 12:18 pm

Thank for for the suggestion, Jeff. However, it doesn`t seem to have cleared up the problem.

Staff
28,434 Points
2014-07-14 1:36 pm
Hello Brenna,

You are correct, the code does not seem to work any longer. After more testing and experimenting with other sites recommendations (all of which did not work either), I finally found one that does work. I have tested it on my own server. Use this code below:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

## hide .php extension
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L,NC]

## To internally redirect /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [L]


Kindest Regards,
Scott M
n/a Points
2014-09-11 5:19 pm

Options +FollowSymLinks -MultiViews # Turn mod_rewrite on RewriteEngine On RewriteBase / ## hide .php extension # To externally redirect /dir/foo.php to /dir/foo RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC] RewriteRule ^ %1 [R,L,NC] ## To internally redirect /dir/foo to /dir/foo.php RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule ^ %{REQUEST_URI}.php [L]

 

This code finally works... spent half a day finding it.

I found other examples but I'd have two versions of the same file whereas with this code I get only one version... THANK YOU SO MUCH

n/a Points
2014-10-20 12:42 am

@Scott M"Options +FollowSymLinks -MultiViews

# Turn mod_rewrite onRewriteEngine OnRewriteBase /## hide .php extension# To externally redirect /dir/foo.php to /dir/fooRewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]RewriteRule ^ %1 [R,L,NC]## To internally redirect /dir/foo to /dir/foo.phpRewriteCond %{REQUEST_FILENAME}.php -f

RewriteRule ^ %{REQUEST_URI}.php [L]"THANK YOU VERY VERY MUCH.. 200% working..after a couple of days search i finally found a working one.. TNX again

 

n/a Points
2014-07-14 1:45 pm

I entered that code into my .htaccess and the .php still shows when I click the link.

Staff
28,434 Points
2014-07-14 2:52 pm
Hello Brenna,

At this point you may want to check with your host as the above code is working on our servers. It is general code so it should work elsewhere but there could be something that is preventing it from working on the server on which you are located.

Kindest Regards,
Scott M
n/a Points
2014-07-16 4:30 am
Hello,
This artical is such a nice artical it will working on localhost very perfectly but when i test it on live server it is not working so plzzz help me..
how can i improve my code give any hint or link of refrence site..
thank u in advance..
I am waiting your reply..
Staff
28,434 Points
2014-07-16 7:50 am
Hello Arpita,

Please try the code below instead to see if it works for you:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

## hide .php extension
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L,NC]


Kindest Regards,
Scott M

## To internally redirect /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [L]
n/a Points
2014-10-17 1:12 pm

Hi! I'm experiencing the same problem: 404 error Page Not Found. I work under Drupal. The url shows correctly (i mean, without the extension), but i get a 404. Any idea? Thanks in advance.

Staff
28,434 Points
2014-10-17 1:26 pm
Hello Munir,

Does it work without Drupal on a test php file?

Kindest Regards,
Scott M
n/a Points
2014-10-17 2:20 pm

Yes it does! May it be because of some problem with Pathauto or another module like that?

Staff
11,186 Points
2014-10-17 2:57 pm
Various modules that change paths such as Patchauto can indeed affect how other rewrites on your site operate. This artice primarily applies to static files and not dynamically written URLs.
n/a Points
2014-07-17 2:15 am

Hello,

Thank you for a code but it is not working on localhost or live server..

error occures 404 not found it is page not found error..

plzz give me other examples..

 

Thank you for reply..

n/a Points
2014-07-17 1:10 am

Hello..

I am working on one project i face one problem related htaccess file..it will run perfectly in localhost but same code is not working on live server in my website..

here i smy code

Options +FollowSymLinksRewriteEngine on RewriteCond %{REQUEST_FILENAME} !-dRewriteCond %{REQUEST_FILENAME}\.php -fRewriteRule ^(.*)$ $1.phpI am use this code its run perfectly but not on server i waste my most of time in that but no result are there so plzz help me..

waitting for your reply what can i do for this problem.. :(

Thank you in advance..

Staff
11,186 Points
2014-07-18 9:31 am
Could you provide me with the URL that you are having trouble with?
n/a Points
2014-07-18 11:35 am

Hello JeffMa,

Yes ofcourse my url is this http://artocean.omexinfotech.com/index.php..

in this url i have problem this is run perfectly in localhost but problem is on live site..

plzz check it and give me suddestion..

thank you..

Staff
25,386 Points
2014-07-18 12:46 pm
Hello Arpita,

We're sorry that you continue to have problems with the removal of the file extensions. The code we have offered works on our servers. It may be different on yours. You may want to check this tutorial from a third party, as it might give you working option.

If it works for you, please let us know!

Regards,
Arnel C.
Staff
11,186 Points
2014-07-18 12:49 pm
We have confirmed that the code itself does work, but it looks like you are hosted with someone else that may be causing issues on their end. I recommend working with your hosting provider for more information.
n/a Points
2014-07-19 4:22 am

Hello JeffMa,

You are right my code is not problem but my hosting server has problem i check that on another server it will run perfectly..so no any issue

but i have another problem about remove query string from url

here is my code:

RewriteEngine on
RewriteCond %{QUERY_STRING} ^service_id=([0-9]*)$
RewriteRule ^servicecnt\.php$ http://artocean.omexinfotech.c... [R=302,L]

code is work perfectly their output url is this:

http://artocean.omexinfotech.com/servicecnt.php/3?service_id=3

that is not correct i required only this not whole url

url http://artocean.omexinfotech.com/servicecnt.php/3

have idea to truncate last characters or any rule of that to remove so plzzzz suggest me...

thank you..

Staff
9,968 Points
2014-07-21 12:13 pm
Hello arpita,

It looks like your RewriteRule got cut off so we can't see the full code that you're using. If you wanted someone going to this URL:

http://example.com/servicecnt.php?service_id=5

To end up at this URL:

http://example.com/servicecnt.php/3

You would use this code:

RewriteEngine On
RewriteCond %{QUERY_STRING} ^service_id=([0-9]*)$
RewriteRule ^servicecnt\.php$ /servicecnt.php/%1? [R=302,L]



The /servicecnt.php/%1? part of the RewriteRule should tell the server to redirect to /servicecnt.php/ followed by the service_id QUERY_STRING, and the ? at the end tells Apache to leave off that query string in the rewritten URL.

Please let us know if you had any further questions at all.

- Jacob
n/a Points
2014-07-22 12:16 am

Hello Jacob,

Your code nice but... url is not proper or 404 vpage not fount error is genrated when i use your code..

http://localhost/servicecnt.php/4  like this  in this url my project folder name is missing so url is not found..

http://localhost/art-ocean/servicecnt.php/4 my actual url is this when this url meet then no error occurs..

so give me modification in that code which is provide by you..

waititng for your reply..

Thank you..

n/a Points
2014-07-25 3:24 am

Hello Jacob,

Any Idea about my issue then plzzz tell me..

I am waiting for your reply..

Thank you very much in advance..

Staff
9,968 Points
2014-07-25 1:45 pm
Hello arpita,

I don't quite understand what you're trying to accomplish with your rewrite rules, are you sure that this is the best method for the scripts you're using? Perhaps if you could explain the purpose of your script it would be easier for us to recommend you something.

When relying on rewrite rules to do something your scripts are handling, you can occasionally run into problems in different server environments. This sounds like the problem you are currently having trying to take your site live.

For instance, if you wanted the URL http://localhost/art-ocean/servicecnt/4 to be a valid address. You could simply place a index.php file inside the directories /art-ocean/servicecnt/4.

Typically you'd remove the file extension of URLs like this guide explains for SEO purposes and to make them more human friendly, but not much can be derived from /art-ocean/servicecnt.php/4 and it still includes the .php extension in the URL which is what this article talks about getting rid of.

If you were getting a 404 error using my previous code example because it ends up redirecting you to:

http://localhost/servicecnt.php/4

Instead of going to where your script expects at:

http://localhost/art-ocean/servicecnt.php/4

Are you placing the .htaccess rules simply in your /public_html/.htaccess file? Or are you putting them inside the /public_html/art-ocean/.htaccess file?

You might need to change it to include the sub-directory if you're just placing the code in your main .htaccess file:

RewriteEngine On
RewriteCond %{QUERY_STRING} ^service_id=([0-9]*)$
RewriteRule ^servicecnt\.php$ /art-ocean/servicecnt.php/%1? [R=302,L]



Please let us know if you have any further questions.

- Jacob
n/a Points
2014-07-26 1:59 am

Hello Jacob,

Thank you very much my url issue is solve i am soooo happy..

but that url design will be changed it may not display..

see i will send you..

so now what can I do plzz give me solution..

waiting for your reply..

here I attach my page..

Staff
9,968 Points
2014-07-26 10:45 am
Hello arpita,

Unfortunately your image wasn't attached successfully. In the future if you could simply place any screenshots or images you're trying to send us onto your website and then just provide a URL to them we can take a look for you.

- Jacob
n/a Points
2014-07-28 12:02 am

Hello Jacob,

Here i send my actual page with design and without rewrite url..

my design like this which i send you previous..

thank you for reply..

Staff
28,434 Points
2014-07-28 8:31 am
Hello Arpita,

Unfortunately images posted into the comments are not allowed and stripped by our server. You will want to simply upload the images to your server and then place a URL in the comment to that image. Then we can take a look for you.

Kindest Regards,
Scott M
n/a Points
2014-07-28 11:58 pm

Hello Jacob,

Here is my url http://artocean.omexinfotech.com/ourservices.php which design is not supported when I rewrite query string url..

Please check it and give me suggestion..

Thank you..

Staff
28,434 Points
2014-07-29 7:29 am
Hello Arpita,

I do see that the services are leading to 404 errors. Unfortunately other than the code we have given we do not know what your server needs. We are unable to test because you are not one of our customers so we have no access to the server, nor its configuration. With the code working in localhost, you can tell it is generally correct. You may need to ask your host if there is anything else needed as they seem to have a configuration that is interfereing.

Kindest Regards,
Scott M
n/a Points
2014-07-30 5:01 am

Hi scott,

Its ok but my code is correct then it is not issue i think my server has a problem when I upload it on client server then problem will be solved..

Thank you..

n/a Points
2014-08-27 1:50 am

Hello,

I have littel problem in wordpress dynamic menu..

My html page css is not working on wordpress dynamic menu so plzz help me..

here i attach one image..

You can here menu beside logo that menu is not proper space between 2 menu is not proper so i have to want make it proper so plzz help me...

 

Thank You..

Staff
28,434 Points
2014-08-27 10:41 am
Hello Arpita,

Unfortunately I do not understand what you are asking. Did you create your own CSS and want it to work in Wordpress? Did you modify existing css file in WordPress? Did you modify it in the WordPress back end?

Also, this particular article is about htaccess files and file extensions, so it is likely better to ask a new question instead of placing it in a non-relevant article so other people can also help.

And once again, images cannot be added to questions or comments. They are stripped out and do not display for anyone.

Kindest Regards,
Scott M
n/a Points
2014-08-28 12:14 am

Hello Scott,

Thamk you for reply..

n/a Points
2014-08-28 1:46 am

Hello Scott,

I want a rewrite url in htaccess..

I want open site with www and also without www so you have any idea about this so plzz share with me..

Plzz help me..

Thank You..

Staff
28,434 Points
2014-08-28 9:55 am
Hello Arpita,

When working with Wordpress, it will display in either www or non-www,whichever you choose. You can, however set the htaccess file to force either one you desire.

A quick search in our search bar up top brought up our article on forcing www or non-www for your site.

I hope that helps you,

Kindest Regards,
Scott M
n/a Points
2014-08-28 12:03 pm

Hello Scott,

Thank you very much for reply..

n/a Points
2014-09-01 2:55 pm

I agree Scott. I doubt this will give any SEO or Security benefit. It is a cute trick someone thought up that I believe will be problematic at best, especially for larger websites that have been around awhile. Nice that someone actually said it, instead of just writing an article that appears to be 100% backed by the writer. Good job.

 

Like you, I am seeing this more and more, but I can't help but think it is a mistake. I would definitely not use the trailing slash because it represents a directory. What about all of the links already pointing to your pages, that you have no control over? They actually do have SEO value. They will turn into 404 errors that Google and other search engines do not like. I believe you have to change all of your internal links. CSS files and images might stop working. It just seems to be a huge risk, especially for higher traffic website.

 

When is the last time you typed in a URL to a nested web file? Most use a link. Stores like Amazon do not do this and they dominate the web. My vote is for "NO!". There are plenty of other things more worthy of your time. Link building, Article writing, Micro data, Accessibility to name just a few.

n/a Points
2014-09-03 12:35 am
Article is excellent... and more helpful thing is that if we ask any question then we gave answer of them from your team so it is very helpful to us.

If I have other query about php or wordpress etc them I will ask question in this article?????

Thank you very much..
Staff
28,434 Points
2014-09-08 8:56 am
Hello Arpita,

Generally we ask that the comments and questions in an article relate to the article topic. You are more than welcome to ask a new question using the 'Ask a Question' link. This way other people that have the same question can also find it easily.

Kindest Regards,
Scott M
n/a Points
2014-09-05 7:50 am
pls send me a pdf for this....
Staff
28,434 Points
2014-09-08 8:59 am
Hello viralpatel,

Unfortunately we do not have pdf files of our articles. However, I will submit an idea to our team on creating specific pdf guides for certain topics. Thank you for that idea!

Kindest Regards,
Scott M
n/a Points
2014-09-06 8:13 am

Hi there.  I just did a copy and paste into the htaccess file and this code is not working.  

Here is a link sample.  http://www.youreunique.net/index?page=our_difference

I too, am a total newbie when it comes to webdesign.  My web guy was a friend and his mother passed away and he bascially disappeared.  We have already exhuasted our advertising/marketing/website budget for the year so any help that I can get will be great appreciated!  

Traci 

 

 

Staff
28,434 Points
2014-09-08 9:01 am
Hello Traci,

If you could reply with your exact code we are happy to test it on our server for you to see if it needs any tweaks.

Kindest Regards,
Scott M
n/a Points
2014-09-07 1:22 am

using this code i am not able to remove the extension from my code.

Staff
28,434 Points
2014-09-08 9:02 am
Hello Viral,

We are happy to take a look for you. Please reply with your code so we may see it.

Kindest Regards,
Scott M
n/a Points
2014-09-17 1:05 am

thank u for this coding.....this code is very usefull for hiding the extension in my site thank u.....

n/a Points
2014-09-24 4:39 pm

Hello Jeff,

 

I tried below in .htaccess

 

Options +FollowSymLinks -MultiViews # Turn mod_rewrite on RewriteEngine On RewriteBase / ## hide .php extension # To externally redirect /dir/foo.php to /dir/foo RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC] RewriteRule ^ %1 [R,L,NC]

 

It does not take me to the page. My file name is mylogin.php. When I login it shows mywebsitename.com/mylogin but, throws error page not found.

Appreciate your help.

 

Thanks,

Hemal

Staff
25,386 Points
2014-09-24 5:30 pm
Hello Hemal,

Sorry for the problem with code. Can you please reply with the code that is listed in your .htaccess file. Make sure the code is separated line by line - as your current copy of the code is unclear. We're not sure how it is set in your .htaccess file without looking at your account.

If you can provide us the exact code (or account information if you're an InMotion customer), then we can investigate the issue further. We do not provide programming services, but we do try to point you in the right direction or provide a solution as long as we have the appropriate information.


Kindest regards,
Arnel C.
n/a Points
2014-10-01 2:52 pm

i have to remove .html from only one url,plz help me

Staff
11,186 Points
2014-10-01 2:59 pm
The following line in your .htaccess file will allow you to remove the file extension from a single file:

RewriteRule ^myfilename$ myfilename.html [L]

n/a Points
2014-10-10 3:40 am

Hello,

This is my site url http://artocean.in/ourservices.php in that i want url dynamic means when I click on any of the services at that time my url is same like this http://artocean.in/servicecnt.php?service_id=4  but I want a url like this http://artocean.in/printing.php?service_id=4  is it possible and possible then how it is possible..

plzzzz help me of this issue..

 

thank you in advance..

Staff
28,434 Points
2014-10-10 9:23 am
Hello Arpita,

I am unsure what you are asking exactly. Could you give more details on what it is you are trying to accomplish?

Also, if this does not relate to removing file extensions, please make it a new question.

Kindest Regards,
Scott M
n/a Points
2014-10-13 12:21 am

Hello,

When I add rule for remove query string then that my page design is not supporting what can I do??

my url is this http://localhost/art-ocean/servicecnt.php/3

and code is here..

RewriteEngine OnRewriteCond %{QUERY_STRING} ^service_id=([0-9]*)$RewriteRule ^servicecnt\.php$ /art-ocean/servicecnt.php/%1? [R=302,L]

is it correct..????

url rewrite is correct but design issue.. :(

and this code is not supporting on live server so i cant send you link..

 

please reply me fast...

Staff
11,186 Points
2014-10-13 11:46 am
Could you clarify what specific design issues you are seeing? Could you provide a screenshot?
n/a Points
2014-10-13 1:54 am

Hello,

How to add .html extenstion in wordpress..

 

please reply..

Staff
28,434 Points
2014-10-13 11:51 am
Hello Arpita,

I am not sure you can do that. I spoke with our WordPress guy and he says not to try and do that as it will cause many problems and require extensive coding to make it work properly.

Kindest Regards,
Scott M
n/a Points
2014-10-20 4:20 am

Hello Scott,

Thank you for supporting.. but my problem is solved.

I use one plugin for that so problem is solved..

thank you..

n/a Points
2014-10-18 8:16 am

hello.

in .htaccess file below page not access.

when i click on my account link.

RewriteRule MyAccount/$ ?do=my_account

so. how i can solve this error ?

thanks..

Staff
28,434 Points
2014-10-20 1:21 pm
Hello pradip,

What is it you are trying to accomplish?

Kindest Regards,
Scott M
n/a Points
2014-10-20 4:31 am

Hello Scott,

Htaccess file is not supporting on live server menas (client server) I add rule of remove .php extenstion that is perfectly work on my localhost but not working on live server..

what is problem on that I dont have any Idea so please help me..

and other issue is this http://artocean.in/ourservices.php first you click on this url and in that page 5 services will be displayed and that click on one of any services and that url is this http://artocean.in/servicecnt.php?service_id=3 in that url i want remove query string(?). and I also add rule for remove query string and result like that which I want but that page design is not displaying so what can I do..

see below I attach one image about my above http://artocean.in/servicecnt.php?service_id=3 issue..

Thank you..

 

Staff
25,386 Points
2014-10-20 1:46 pm
Hello Arpita,

Sorry you're having problems with the redirects. However, you do need to provide us more information in order for us to help you with the re-direct issues you have indicated. Can you provide a us a URL where the issue is happening? And you can provide use the code that you are currently using? Please make sure to provide this information as well as any exact error messages you may be seeing.

If you can provide us this information we can try to provide further assistance with the problem you are having.

Regards,
Arnel C.
n/a Points
2014-11-15 4:11 am

Hello Arn,

I have to provide url in previous message but I send again this is my url http://artocean.in/servicecnt.php?service_id=3..

and code is this

Options +FollowSymLinksRewriteEngine on RewriteCond %{REQUEST_FILENAME} !-dRewriteCond %{REQUEST_FILENAME}\.php -fRewriteRule ^(.*)$ $1.phpRewriteEngine OnRewriteCond %{QUERY_STRING} ^service_id=([0-9]*)$RewriteRule ^servicecnt\.php$ /art-ocean/servicecnt.php/%1? [R=302,L]

i want remove query string from http://artocean.in/servicecnt.php?service_id=3 url and also add extestion .html in all page..

.html extension is not working on live site.. but working on localhost perfectly so please help me..

any change will be require on my server????

Waiting for reply..

Thank you..

 

Staff
28,434 Points
2014-11-17 10:06 am
Hello Arpita,

In visiting your site, I noticed it is running off of Microsoft IIS. We are not able to provide support for anything running off of a MS server as we do not use them. Our servers are all Linux based so any advice we give here is only based on those types of servers. We do not have any MS servers so we are unable to test and give correct advice.

Kindest Regards,
Scott M
n/a Points
2014-11-15 4:13 am

Helllo Arn,

http://ravielectricals.in/ this is my other site which has same issue like not run with .html extenstion if i have add that in .htaccess file.

my all pages save with .php but i want that all with .html extenstion.. so what can i do any changes perform on server??

 

Thank you.. please reply

Staff
28,434 Points
2014-11-17 10:10 am
Hello Arpita,

For Apache servers the code to switch php to html should be something like this:
RewriteEngine on
RewriteBase /

RewriteCond %{THE_REQUEST} (.*)\.php
RewriteRule ^(.*)\.php $1.html [R=301,L]

RewriteCond %{THE_REQUEST} (.*)\.html
RewriteRule ^(.*)\.html $1.php [L]


As I am not an expert in htaccess, this answer was sourced from stack overflow.

Kindest Regards,
Scott M
n/a Points
2014-11-27 5:34 am

Hi I have tried your code but it gives an error 404 when i follow address in addressbar. My website name is Ludhianaweds.com. When i type ludhianaweds.com/aboutus it gives an error 404. Here are two same files in my main directory with the names aboutus and aboutus.php.Any help ??Thanks in advance....

Staff
17,092 Points
2014-11-28 1:26 pm
Hello Ashish,

Thank you for contacting us. When I tested the "aboutus" page you linked to, I am not seeing a 404 error. Are you still experiencing issues at this time?

You may have to clear your Browser Cache before testing again.

Thank you,
John-Paul
n/a Points
2014-12-17 11:19 am

Hi Guys,

See you are resolving some issues here. Have a simiar problem with multiview being enabled to get rid of the the file extension .php globaly across the site, but now not all the 301 redirect's work. We have lots of old inbound (good quality) links that need to go to new urls.In the htaccess file this worksRedirect 301 /files/Menu.pdf http://www.example.co.ukThis works but puts a trail of the url onto the redirected urlRedirect 301 /section.php/11/1/life-drawing http://www.example.co.ukThis doesn'tRedirect 301 /section/116/1/drawings http://www.example.co.ukHere are the contents of the htaccess file...RewriteEngine onRewriteCond %{HTTP_HOST} ^example.co.uk [NC] RewriteRule ^(.*)$ http://www.example.co.uk/$1 [L,R=301]RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/ RewriteRule ^index\.php$ http://www.example.co.uk/ [R=301,L] RewriteEngine onOptions +SymlinksIfOwnerMatch +MultiViewsRewriteRule ^(.*).php/(.*) $1.php?$2Redirect 301 /files/GalvinCognacCigarMenu.pdf http://www.example.co.ukRedirect 301 /section.php/11/1/life-drawing http://www.example.co.ukRedirect 301 /section/116/1/drawings http://www.example.co.ukAny help would be very much appreciated. ThanksPeter

Staff
25,386 Points
2014-12-17 12:30 pm
Hello P Garner,

Sorry to hear that you're having problems with the re-directs not working. It does appear however, that you will need to re-write your re-directs to take in account the removal of the PHP extensions. We can't provide the re-write for you, but hopefully, looking at some examples from other discussions on this issue, you will find a solution. Check out this discussion as it seems to closely resemble the issue that you are facing.

I hope this helps to answer your question, please let us know if you require any further assistance.

Regards,
Arnel C.
n/a Points
2014-12-17 1:01 pm

Hi Arnel,

Thank you so much for your reply. I had a look at that link and they say 'works well except for pages that have 301 redirects.'So my message want posted very well.The removal of .php works fine with the multiview. We are concerned about incoming links going to old pages with .php and cant seem to redirect these.In the htaccess file this works

Redirect 301 /files/Menu.pdf http://www.example.co.ukThis works but puts a trail of the url onto the redirected url (which is ok for now)Redirect 301 /section.php/11/1/life-drawing http://www.example.co.ukThis doesn'tRedirect 301 /section/116/1/drawings http://www.example.co.ukHere are the contents of the htaccess file...RewriteEngine onRewriteCond %{HTTP_HOST} ^example.co.uk [NC] RewriteRule ^(.*)$ http://www.example.co.uk/$1 [L,R=301]RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/ RewriteRule ^index\.php$ http://www.example.co.uk/ [R=301,L] RewriteEngine onOptions +SymlinksIfOwnerMatch +MultiViewsRewriteRule ^(.*).php/(.*) $1.php?$2Redirect 301 /files/GalvinCognacCigarMenu.pdf http://www.example.co.ukRedirect 301 /section.php/11/1/life-drawing http://www.example.co.ukRedirect 301 /section/116/1/drawings http://www.example.co.uk

is there any expert help i can pay for?ThanksPeter

Staff
25,386 Points
2014-12-18 3:44 am
Hello Peter,

Sorry again for the problem with the re-direct. Unfortunately, we do not provide services to write the code for you. However, the link I initially provided states that THEIR code does not work well with 301 re-directs, but the reply includes a response that may have the solution to that problem. Since your 301 re-directs are not redirecting you may need to change them to not include the PHP extensions. If this does not resolve the issue for you, then you will need to seek a programmer for further assistance with that issue.

You may also want to review the documentation provided y Apache for multiview for further possible clues on correcting the issue with your code.

Regards,

Arnel C.
n/a Points
2014-12-18 4:55 pm

I've tried using the code above however for some strange reason it seems to work for my entire website with the exception of just 2 pages and I can't find why?!?

I've kept the .html at the end of the two pages not working for now just so the site is functional but to show you my problem I have created a duplicate of my home page at: http://www.riverinatradies.com.au/index2

If you click on the directory link you will find a sub-menu that has wagga wagga albury wodonga and girffith. When clicked the wagga wagga link ads a trailing slash to the link and displays the page links instead of the page itself. In the same sub-menu, the Albury Wodonga links works perfectly fine and Griffith link has the same problem above.

Any help you can provide would be greatly appreciated!! :-)

Staff
17,092 Points
2014-12-18 5:28 pm
Hello Libby,

Thank you of your question. When I checked the "wagga wagga" link, I noticed it is just a link to a folder (directory-wagga), instead of a page. Since there is no index.html, index.php, or default.htm, it just lists the directories.

I would compare the "wagga wagga" link, to the "Albury Wodonga" links, to see how they are coded. Most likely the "Albury Wodonga" link is coded differently, from the other two.

I also recommend reviewing the existing .htaccess rules, as they may be interfering with this one.

If you have any further questions, feel free to post them below.

Thank you,
John-Paul
n/a Points
2014-12-18 8:19 pm

Ah John-Paul you're a legend!! How did I not see that? lol

Thank you so much for not only getting back to me so quickly but for solving my problem, that will be fixed quite simply now that I can see what it is. Again, a million thank you-'s ! :-)

2014-12-19 2:29 am
Hello sir, I have seen some results in Google search like "yourdomain.com > file > subfile". While Google shows results for my website like "yourdomain.com/file/subfile". How can i get Google search results like "yourdomain.com > file > subfile" ??

My .htaccess is

Options +FollowSymLinks
Options -Multiviews
RewriteEngine on

ErrorDocument 404 /error404.php

RewriteBase /
# Remove .php extension
RewriteCond %{THE_REQUEST} ^GET\ /[^?\s]+\.php
RewriteRule (.*)\.php$ /$1/ [L,R=301]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/(.+)/$
RewriteCond %{DOCUMENT_ROOT}/%1.php -f
RewriteRule ^(.*)/$ $1.php [L]

RewriteRule ^([^/.]+)/?$ /vendorlist.php?bcat=$1
RewriteRule ^([^/.]+)/([^/.]+)/?$ /vendor.php?bcat=$1&vendor=$2

Thanks in advance...
Staff
28,434 Points
2014-12-19 9:02 am
Hello AshishGarg,

Thank you for your question. I am not quite understanding it, however. Would you be able to provide a link to an example of what you are asking? Are you asking to literally change the / to a > ?

Kindest Regards,
Scott M
2014-12-20 1:59 am
Absolutely Scott Sir.....I want to change "/ to a >" in Google search results...Thanks
Staff
17,092 Points
2014-12-20 8:51 am
Hello AshishGarg,

Thank you for your question. I spent some time looking into this for you. Unfortunately, I do not know a way to change a "/" to a ">" symbol, as it may cause problems when the browser attempts to render the URL.

Thank you,
John-Paul
n/a Points
2014-12-30 7:30 am
nice and so helpful
n/a Points
2015-01-28 7:25 am

Hello,

This is my page url http://www.artocean.in/aboutus.php .. in this i want rewrite url i want add .html extenstion and remove .php extenstion.. but that is not working error occurs Not Found error occurs.

And I want code for working on live server.. i am very tried to solve this issue...

If anybody have solution then pleaseeeeeee share here..

 

Thank you...

Staff
25,386 Points
2015-01-28 11:17 am
Hello Arpita,

The problem with what you're trying to do is exactly the error you're running into - the file doesn't exist. You should either create a re-direct to point to the .php page, or simply get RID of the extension altogether as per the article above. It's better for your SEO as it becomes a much easier to read URL. We're not sure what benefit you would get for using the HTML extension versus the PHP extension.

Kindest regards,
Arnel C.
n/a Points
2015-02-20 3:49 pm

Hi, I've tried everything I can think of and keep ending up with the answer of "folder" which makes no sense. My problem is I have a sitewide EV SSL. I want to force the  SSL to apply to pages with specific extension, namely, .html.  The site is a mix of .php and .html and this is where it gets weird.

With NO code in the .htacces file, if you manually force the SSL by adding the s to http. for example: https://www.erpsaa.com/ then every single .html page remains secure including the form where clients send us confidential information. PERFECT.

When you go to any .php menu in the pull down, for example: http://erpsaa.com/solutions-vmware-best-in-class-virtualization.php

It kicks off the s, which is what I want because I share content with VMware and the .PHP pages will become distorted if the SSL is applied. However, they seemed to knock the site right out of secure. THE PROBLEM: Once out of secure, leave the any of the .php pages and the .HTML fails to engare the SSL, for the simple reason is that I did it manually in the first place. So why, when I redirect the entire site am I still in a mess, since the code below obviously directs the entire site from http to https permanently:

RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://www.erpsaa.com/$1 [R=301,L]The problem is now over 1,200 .php pages are all a mess because unlike when you redirect the entire site, unlike manually putting placing the .html pagesinto https, although it stays secure on all .html, it knocks off the s when you any .php page. That does not happen will a full site direct, it forces all the .php pages as well. I'm going to try this: RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://www.erpsaa.com/index.html$1 [R=301,L]Something tells me it won't work. Why is it so difficuly to find the answer with a search "301 redirectfor pages with a specific extension only." Thanks for any help. Dean

 

 

 

 

Staff
4,330 Points
2015-02-22 10:39 pm
Hello,

You could trying doing something like the following.


RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.yourdomain.com/folder/$1 [R,L]


So pretty much this means, for any .htm or .html file that is accessed on port 80, redirect to ssl version.

Best Regards,
TJ Edens
n/a Points
2015-03-02 10:36 am

TJ, I finally found your reply, thank you. The code below if you remove the word folder is a complete site rewrite and it works.

So, let me give it a shot, and I assume you mean by folder, the .html folder, /public_html, thus:

RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://www.erpsaa.com.com/fpublic_html/$1 [R,L]

Thanks again, I was at the point of trying to do it page by page in ths way:

# Permanent URL redirect 

Redirect 301 www.erpsaa.com/contact-us.html https://www.erpsaa.com/contact-us.html

which worked perfectly, until I added a second page.

Thanks again,

Dean

 

n/a Points
2015-02-28 2:24 am

Hello Arnel,

Thank you for replying but my problem is solved...

 

Thank you again for future support...

n/a Points
2015-03-30 4:43 am

i am writing a program to create nested directory and create file at last directory. here is a program, which is creating directories.

<?php

function make_path($path){
    $dir = pathinfo($path,PATHINFO_DIRNAME);if(is_dir($dir)){returntrue;}else{if(make_path($dir)){if(mkdir($dir)){
                        chmod($dir,0777);returntrue;}}}thrownewException("This Directory is available");}try{
$url ="http://www.w3schools.com/php/php_ref_string.asp";
$remove_http = str_replace('http://','', $url);
make_path($remove_http);
$tv = explode('/',$remove_http);for($x=0;$x<count($tv)-1;$x++)
echo "<br/>".$tv[$x];
echo "<br>".end($tv);}catch(Exception $e){
echo $e->getMessage();}?>................................................................... this program is creating first folder named 'www.w3schools.com', second folder named 'php' in first folder. but php file is not saving in the second folder. please help.......
Staff
25,386 Points
2015-03-30 7:49 am
Hello Sudhakar,

Thank you for your question in regards to your program. Unfortunately, we do not provide support of that nature with the Support Center. You will need to work with a programmer/developer for help with that issue.

Kindest regards,
Arnel C.
n/a Points
2015-04-08 3:25 am

Hello..

I want enable in my custom post type in wp-admin.. I added screen Option but their menu is not dispalying menus like(Author Comments Date).. this type 

And one other question how to create capability in wordpress means for perticular plugin or post type with perticular name or keyword that is connect to perticular plugin or post type...

If you know than please share.. 

 

Many Thanks...

n/a Points
2015-05-02 11:17 am

Nice Posting Sir

Thanks Alot with my hearts

n/a Points
2015-05-05 1:12 am

HI,

 i want to htaccess for like example.com/test.php?para=birds to change as

example.com/test/birdscould you tell anyone how to write .htacces for this.

 

Thank in advance....

 

Staff
25,386 Points
2015-05-06 8:16 am
Hello Venu,

You will need to work with query strings within the .htaccess rule. Checkout this tutorial. Basically, the rule will look like this:

RewriteCond %{QUERY_STRING} ^para=birds$
RewriteRule ^test\.php$ http://example.com/test/birds.php [R=302,L]

I hope this helps to answer your question, please let us know if you require any further assistance.

Regards,
Arnel C.
n/a Points
2015-06-04 3:22 pm

how i can remove hyperlink from my website hold page please advice asap 

 

thanks 

Staff
17,092 Points
2015-06-04 3:27 pm
Hello joy,

Thank you for contacting us. It depends how your site/hyperlink was created. We are happy to help, but will need some additional information.

What CMS are you using? For example, WordPress, Joomla, Concrete5, etc.

Can you provide a link to the site with the hyperlink?

Thank you,
John-Paul
n/a Points
2015-07-10 1:34 am

HI

n/a Points
2015-07-13 4:17 pm

Hi, how would I put the code in for removing the .php AND the .html file extension, since I use both..? Thanks!!

Staff
25,386 Points
2015-07-13 4:29 pm
Hello Lance,

The instructions in the article explain how to use it in the .htaccess file. These instructions are used to remove the extensions from appearing in the URL. If you're asking for something different, then please let us know exactly what you're trying to do.

Regards,
Arnel C.
n/a Points
2015-07-19 5:40 pm

Thanks a lot, very very helpful compared to the thousand of answers on google.

Post a Comment

Name:
Email Address:
Phone Number:
Comment:
Submit

Please note: Your name and comment will be displayed, but we will not show your email address.

114 Questions & Comments

Post a comment

Back to first comment | top

Need more Help?

Search

Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail: support@InMotionHosting.com
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!