# Help with not having to put .html at end of link?



## SVTCobraLTD (Nov 18, 2007)

I just switched hosting companies and now I cannot access my site by going to www.mysite.com/webpage instead I have to type www.mysite.com/webpage.html

What do I need to do in order for the .html to not be required? There are a lot of links out there without the .html and they no longer work. Thank you in advance.

SVT


----------



## TechGuy (Feb 12, 1999)

There's a couple of things you could do. The easiest (depending on how many pages you have) would probably be to create a directory called "webpage" and put "webpage.html" in there, but rename it to "index.html".

The other option, assuming your web server is running Apache, would be to do some kind of RewriteRule in a .htaccess file.

Here are some examples: http://tomclegg.net/rewriterule


----------



## SVTCobraLTD (Nov 18, 2007)

I have about 25 pages and they change all the time so I do not want to do the folder deal.

I looked at the link you provide and edited my .htaccess file to have


> # .htaccess in root of example.com
> RewriteRule ^/?([^/]*\.html?|[^\./]*)[:;,\.]*$ /foo/show.php [L,NS]


 in it but it still is not working? What am I doing wrong?

SVT


----------



## Anthony:-P (Nov 24, 2006)

Hi,

do you have the site to show us?

Also, i believe the erro may be that "/foo/show.php" doesn't exist on your server, therefore it can't find the file and/or display it...

You should try the following:

*.PHP extensions

```
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ $1.php [L,QSA]
```
*HTML extensions

```
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ $1.html [L,QSA]
```
Regards,
Anthony


----------



## SVTCobraLTD (Nov 18, 2007)

When I put


> RewriteEngine On
> RewriteCond %{REQUEST_FILENAME} !-f
> RewriteCond %{REQUEST_FILENAME} !-d
> RewriteRule ^(.*)$ $1.html [L,QSA]


 into my htaccess file it made my site give an error 500 on the main page.

web site is www.PennMustangs.com but if you go to www.PennMustangs.com/store it will not work, yet www.PennMustangs.com/store.html will.

SVT


----------



## Anthony:-P (Nov 24, 2006)

Hi,

can you try the php one for me please? just save the/a file as .php and then set the .php rewrite rule 

Regards,
A...


----------



## SVTCobraLTD (Nov 18, 2007)

Anthony:-P said:


> *.PHP extensions
> 
> ```
> RewriteEngine On
> ...





Anthony:-P said:


> Hi,
> 
> can you try the php one for me please? just save the/a file as .php and then set the .php rewrite rule
> 
> ...


When I did the one quoted above, my site gave error 500. Here is a copy of the error.



> Internal Server Error
> The server encountered an internal error or misconfiguration and was unable to complete your request.
> Please contact the server administrator, [email protected] and inform them of the time the error occurred, and anything you might have done that may have caused the error.
> 
> ...


Below is a copy of the server error log


> [Mon Dec 17 10:56:43 2007] [alert] [client XXXXXXX] /home/public_html/.htaccess: Invalid command '\xd0\xcf\x11\xe0\xa1\xb1\x1a\xe1', perhaps mis-spelled or defined by a module not included in the server configuration
> [Mon Dec 17 10:56:43 2007] [alert] [client XXXXXX] /home/public_html/.htaccess: Invalid command '\xd0\xcf\x11\xe0\xa1\xb1\x1a\xe1', perhaps mis-spelled or defined by a module not included in the server configuration


SVT


----------



## TechGuy (Feb 12, 1999)

Make sure you're uploading the .htaccess and .php files as ASCII and not Binary. Also, make sure you're using something like Notepad to edit them (and not Microsoft Word).


----------



## SVTCobraLTD (Nov 18, 2007)

Thank you.. I forgot and was editing it in word and that was the problem. Once I did it in notepad, it worked fine. Thanks again, this is a great site. I see your from PA as well.

SVT


----------



## TechGuy (Feb 12, 1999)

Glad we could be of some help! It's always nice to see a team effort here.

Looks like you're site is moving along nicely. Don't forget we always appreciate a link back, even if it's just in a forum post. 

Where abouts are you in PA? I live in Chambersburg, PA -- just of I-81 near Gettysburg.


----------



## SVTCobraLTD (Nov 18, 2007)

I am in Quakertown, about 2 hours SE of you I believe.


----------



## TechGuy (Feb 12, 1999)

One of our Moderators, Anne Troy (previously known as Dreamboat) also lives in Quakertown. I've driven past a few dozen times coming to/from NYC.


----------



## Anthony:-P (Nov 24, 2006)

SVTCobraLTD said:


> Thank you.. I forgot and was editing it in word and that was the problem. Once I did it in notepad, it worked fine. Thanks again, this is a great site. I see your from PA as well.
> 
> SVT


Glad it worked for you 

Regards,
A...


----------



## SVTCobraLTD (Nov 18, 2007)

TechGuy said:


> One of our Moderators, Anne Troy (previously known as Dreamboat) also lives in Quakertown. I've driven past a few dozen times coming to/from NYC.


Small world.

SVT


----------



## briealeida (Jun 3, 2007)

CGI is another way to solve this, if anyone is interested.


----------



## SVTCobraLTD (Nov 18, 2007)

My new hosting site if i have a page called testpage.html then when i got to mysite.com/TESTPAGE it would give me an error saying no page, yet if i go to mysite.com/testpage it will work fine. It that another edit in the htaccess file?


----------



## Anthony:-P (Nov 24, 2006)

SVTCobraLTD said:


> My new hosting site if i have a page called testpage.html then when i got to mysite.com/TESTPAGE it would give me an error saying no page, yet if i go to mysite.com/testpage it will work fine. It that another edit in the htaccess file?


Hi Again,

Most are case sensitive, it's like (for example) www.mysite.tld/SomeDirectory would not be the same as www.mysite.tld/somedirectory. Never seen a htaccess fix for it, but i'll rummage around some files and the internet and see what i can dig out that may be of use.

As briealeida has stated above, CGI is another way to go about this if you wish (i've never really used CGI, so i can't help there).

Regards,
Anthony


----------

