Webmaster Forum


Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.


Reply
 
LinkBack Thread Tools Display Modes
Share |
  #1 (permalink)  
Old 11-11-2011, 07:35 AM
Contributing Member
Latest Blog:
None

 
Join Date: 10-29-10
Posts: 539
iTrader: 0 / 0%
How to remove .htm from address bar?

Hi,

I'd like to remove the .htm and .php extensions from my site page addresses in the browser address bar.

This is what I have:

http://www.mysite/folder/page.htm

This is what I want:
http://www.mysite/folder/page

Or:
http://www.mysite/folder/page/

I know it has something to do with access files, just unsure how to modify them...
 
Reply With Quote
  #2 (permalink)  
Old 11-11-2011, 04:35 PM
Member
 
Join Date: 11-09-11
Posts: 33
iTrader: 0 / 0%
do a search on google for URL rewrite. its pretty commom but also depends on what type of server youre running on.
__________________
Presidents Cup 2011
Golf Girls
 
Reply With Quote
  #3 (permalink)  
Old 11-12-2011, 04:08 AM
Contributing Member
Latest Blog:
None

 
Join Date: 10-29-10
Posts: 539
iTrader: 0 / 0%
I just need a simple script or whatever to set this. I believe it has to be done in the htaccess file.

I found all sorts of complex things in Google, but not this simple thing that I'm looking for.
 
Reply With Quote
  #4 (permalink)  
Old 11-12-2011, 05:17 AM
Contributing Member
Latest Blog:
None

 
Join Date: 10-29-10
Posts: 539
iTrader: 0 / 0%
I tried this, entered into my already existing .htaccess file and it is not working

PHP Code:
RewriteEngine On
RewriteCond 
%{REQUEST_FILENAME} !-f
RewriteRule 
^([^\.]+)$ $1.htm [NC,L

Last edited by snakeair; 11-13-2011 at 05:03 AM.
 
Reply With Quote
  #5 (permalink)  
Old 11-13-2011, 05:01 AM
Contributing Member
Latest Blog:
None

 
Join Date: 10-29-10
Posts: 539
iTrader: 0 / 0%
Finally I managed to solve the problem like this/with this, longer, slightly adjusted code:

RewriteCond %{THE_REQUEST} ^[A-Z]+\ /([^/\ ]+/)*[^.\ ]+\.htm\ HTTP/
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(([^/]+/)*[^.]+)\.htm$ http://www.mysite.com/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ http://www.mysite.com/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME}.htm -f
RewriteRule ^(([^/]+/)*[^./]+)$ /$1.htm [L]


For those of you, who'd like to do the same thing, you must place this code into the .htaccess file and, you must also:

-set permissions: 6-4-4 for files
-set permissions: 7-5-5 for folders
 
Reply With Quote
Go Back   Webmaster Forum > Web Development > Coding Forum

Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to show IP instead of Address In Address bar zzz_va2002 Coding Forum 1 07-27-2010 06:33 PM
My HJT log - what can I remove? Kalina Tech Talk 7 03-25-2006 06:29 PM


V7N Network
Get exposure! V7N I Love Photography V7N SEO Blog V7N Directory


All times are GMT -7. The time now is 02:06 AM.
Powered by vBulletin
Copyright © 2000-2013 Jelsoft Enterprises Limited.
Copyright © 2003 - 2013 Escalate Media LP




Search Engine Optimization by vBSEO 3.6.0 RC 2 ©2011, Crawlability, Inc.