There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
acer black screen blue screen blue screen of death boot computer connection crash css dell display driver drivers email error excel firefox firefox 3 game hard drive internet internet explorer itunes laptop lcd linux malware monitor network networking outlook outlook 2003 outlook express partition password printer problem ram router slow software sound startup trojan usb virus vista windows windows xp wireless
Web Design & Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Internet & Networking > Web Design & Development >
.htaccess question


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

Closed Thread
 
Thread Tools
The Infinity's Avatar
Senior Member with 575 posts.
 
Join Date: May 2005
Location: Florida
Experience: Advanced
27-Nov-2006, 12:34 AM #1
Question .htaccess question
I was told a while ago that I could change my .htaccess to know when the URL said something like http://www.mysite.com/home.php that in the address bar it would automatically see it as http://www.mysite.com/home and it would display that in the address bar.

The person that told me this was a little unclear about how to do it. I was wondering if someone could give me a better explaination of how I can go about doing this.

- Thanks
__________________
Soft Hardware
OS Windows Media Center Edition 2005
Case Aspire X-Dreamer II
CPU Intel Pentium 4 3.2GHz Prescott 1MB L2-Cache
RAM Patriot Extreme Performance 2048 MB
Video Card Nvidia GeForce 6600 GT 128MB AGP8X
Hard Drive 80 Gigabyte Western Digital
Cooling System 1 - 120mm, 3 - 80mm, 3 - 40mm
CRT Moniter CTX VL700 Series [17" CRT] 1024 x 768 @ 75 Hertz
Power Supply Antec 420w
Disk Drives HP DVD-RW w/ Lightscribe Technology, HP CD-RW, and 3 1/2inch Floppy.
knight_47's Avatar
Senior Member with 1,187 posts.
 
Join Date: Mar 2006
Location: →
Experience: Um... Green?!
27-Nov-2006, 12:38 AM #2
RewriteEngine On
RewriteRule ^home(/)?$ home.php
RewriteRule ^video(/)?$ video.html
RewriteRule ^pictures(/)?$ pictures.htm

Just add the above code to your .htaccess file, I have given 3 examples, all the bold are the parts that need to be edited out.

By the way, the reason (/) is in the RewriteRule is so you can have yoursite.com/pictures OR yoursite.com/picutres/ and they will both work.

Thanks namenotfound...
__________________
The Infinity's Avatar
Senior Member with 575 posts.
 
Join Date: May 2005
Location: Florida
Experience: Advanced
27-Nov-2006, 01:42 AM #3
Awesome. Will I need to add this for ever page I make?

Such as if I create a page called turtles.php will I need to go into the htaccess page and make the change:

RewriteEngine On
RewriteRule ^home(/)?$ home.php
RewriteRule ^video(/)?$ video.html
RewriteRule ^pictures(/)?$ pictures.htm
RewriteRule ^turtles(/)?$ turtles.php

?
__________________
Soft Hardware
OS Windows Media Center Edition 2005
Case Aspire X-Dreamer II
CPU Intel Pentium 4 3.2GHz Prescott 1MB L2-Cache
RAM Patriot Extreme Performance 2048 MB
Video Card Nvidia GeForce 6600 GT 128MB AGP8X
Hard Drive 80 Gigabyte Western Digital
Cooling System 1 - 120mm, 3 - 80mm, 3 - 40mm
CRT Moniter CTX VL700 Series [17" CRT] 1024 x 768 @ 75 Hertz
Power Supply Antec 420w
Disk Drives HP DVD-RW w/ Lightscribe Technology, HP CD-RW, and 3 1/2inch Floppy.
watchintv's Avatar
Computer Specs
Senior Member with 128 posts.
 
Join Date: May 2005
Location: The Left-Coast
Experience: Web Designer
27-Nov-2006, 02:10 AM #4
I am also positive that there is another way to do it with out having to keep adding the name of the page to the htaccess page. I've done it before, but cant remember how you do it. Ill look it up.
watchintv's Avatar
Computer Specs
Senior Member with 128 posts.
 
Join Date: May 2005
Location: The Left-Coast
Experience: Web Designer
27-Nov-2006, 02:14 AM #5
Found it, I think.

Try adding just this

HTML Code:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ $1.php [L,QSA]
namenotfound's Avatar
Computer Specs
Distinguished Member with 2,198 posts.
 
Join Date: Apr 2005
Location: New York
Experience: I know what I know, I am
27-Nov-2006, 07:28 AM #6
@watchintv that's cool I didn't know about that one


The method I told Knight is good if you want relevant urls, such as if you have a site with articles and you want the urls to be dated. Such as:

site.com/November/27/2006/world-peace-starts

Instead of creating all those directories, you could do something like this:

RewriteRule ^November/27/2006/world-peace-starts(/)?$ worldpeace.php

The actual file would be at site.com/worldpeace.php but you'd see in the address bar site.com/November/27/2006/world-peace-starts


__________________
-----------------------------
| 404: Name Not Found |
-----------------------------
PLEASE NOTE: If I happen to help you in a post, or just simply reply to it, doesn't mean I want to be bombarded with PMs. I answer all questions in posts, not in PMs. Thank you, and have a good day.

<?php $h = 'Hello '; $w = 'World'; echo $h.$w; ?>

My Favorite Editors:
Windows: Crimson Editor
Mac: Taco HTML Edit
Linux: gPHPEdit
The Infinity's Avatar
Senior Member with 575 posts.
 
Join Date: May 2005
Location: Florida
Experience: Advanced
27-Nov-2006, 04:54 PM #7
Sorry if this is a bit of a dumb question since I'm really new to the .htaccess part. But all I have to do is add:

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

to my .htaccess and that should take care of my problem?
knight_47's Avatar
Senior Member with 1,187 posts.
 
Join Date: Mar 2006
Location: →
Experience: Um... Green?!
27-Nov-2006, 05:16 PM #8
Quote:
Originally Posted by The Infinity
Sorry if this is a bit of a dumb question since I'm really new to the .htaccess part. But all I have to do is add:

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

to my .htaccess and that should take care of my problem?
Yup, it's that easy.

But I have a question, will this work if I have php, html, and htm files? Or do I need to modify the last line??
The Infinity's Avatar
Senior Member with 575 posts.
 
Join Date: May 2005
Location: Florida
Experience: Advanced
27-Nov-2006, 05:30 PM #9
Quote:
Originally Posted by knight_47
Yup, it's that easy.

But I have a question, will this work if I have php, html, and htm files? Or do I need to modify the last line??
Thats what I was wondering to because on the FTP server the files are called index.php with the .php ending.

Do I need to change anything, because I put it onto the .htaccess below everything else I have in that .htaccess file and it didn't work. I received a 404 error when I tried to take .php off the end in the address bar.
__________________
Soft Hardware
OS Windows Media Center Edition 2005
Case Aspire X-Dreamer II
CPU Intel Pentium 4 3.2GHz Prescott 1MB L2-Cache
RAM Patriot Extreme Performance 2048 MB
Video Card Nvidia GeForce 6600 GT 128MB AGP8X
Hard Drive 80 Gigabyte Western Digital
Cooling System 1 - 120mm, 3 - 80mm, 3 - 40mm
CRT Moniter CTX VL700 Series [17" CRT] 1024 x 768 @ 75 Hertz
Power Supply Antec 420w
Disk Drives HP DVD-RW w/ Lightscribe Technology, HP CD-RW, and 3 1/2inch Floppy.
watchintv's Avatar
Computer Specs
Senior Member with 128 posts.
 
Join Date: May 2005
Location: The Left-Coast
Experience: Web Designer
27-Nov-2006, 05:59 PM #10
To be honest with ya, I have no clue how it works. I just had the site I saw it on bookmarked in firefox.
The Infinity's Avatar
Senior Member with 575 posts.
 
Join Date: May 2005
Location: Florida
Experience: Advanced
27-Nov-2006, 08:14 PM #11
Quote:
Originally Posted by watchintv
To be honest with ya, I have no clue how it works. I just had the site I saw it on bookmarked in firefox.
Great
watchintv's Avatar
Computer Specs
Senior Member with 128 posts.
 
Join Date: May 2005
Location: The Left-Coast
Experience: Web Designer
27-Nov-2006, 08:17 PM #12
lol, im sure somebody knows.
The Infinity's Avatar
Senior Member with 575 posts.
 
Join Date: May 2005
Location: Florida
Experience: Advanced
27-Nov-2006, 08:18 PM #13
Quote:
Originally Posted by watchintv
lol, im sure somebody knows.
I sure do hope so, I have been having this problem forever
namenotfound's Avatar
Computer Specs
Distinguished Member with 2,198 posts.
 
Join Date: Apr 2005
Location: New York
Experience: I know what I know, I am
27-Nov-2006, 08:20 PM #14
Forever? Your first post in this thread was at 12:34 AM today (EST)
The Infinity's Avatar
Senior Member with 575 posts.
 
Join Date: May 2005
Location: Florida
Experience: Advanced
27-Nov-2006, 08:24 PM #15
Quote:
Originally Posted by namenotfound
Forever? Your first post in this thread was at 12:34 AM today (EST)
Lol, I have had the problem longer than that, I had a post way back and I had, had the problem a few months before that post. I just let it go until my members started to complain.
Closed Thread

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who help people like you solve computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 03:48 PM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.