hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Hosting Security and Technology : Rewrite question
Reply

Hosting Security and Technology Configuring and optimizing web hosting servers and operating systems, developing administration scripts, building servers, protecting against hackers, and general security (SSL certificates, etc.)
Forum Jump

Rewrite question

Reply Post New Thread In Hosting Security and Technology Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 03-28-2009, 06:49 PM
Kurogane Kurogane is offline
WHT Addict
 
Join Date: Jan 2008
Posts: 100

Rewrite question


How i can rewrite this

http://www.yourdomain.com/example.html to http://www.yourdomain.com/example

And then only use this url http://www.yourdomain.com/example

I know is very simple but i can't find how i can do this.

Thanks

Reply With Quote


Sponsored Links
  #2  
Old 03-28-2009, 09:26 PM
mwatkins mwatkins is offline
Web Hosting Master
 
Join Date: Nov 2001
Location: Vancouver
Posts: 2,416
It's the other way around. You are rewriting http://yourdomain.com/example to the version ending in .html. I'm doing this from memory, assuming you are using Apache. When asking questions about rewriting it's best to specify which web server you are running because believe it or not, the entire world does not run Apache.

Code:
RewriteRule ^/example/$    /example.html [L]
Lets say for example ALL your current URLs/files end in .html and you want to hide that implementation detail:

Code:
RewriteRule ^(/.+)/$         $1.html [L]
Try it and play.

Your mileage may vary.

Become familiar with The Apache Rewrite Guide: http://httpd.apache.org/docs/2.2/rew...ite_guide.html

Don't run with scissors.

__________________
“Even those who arrange and design shrubberies are under
considerable economic stress at this period in history.”

Reply With Quote
  #3  
Old 03-29-2009, 02:01 AM
Kurogane Kurogane is offline
WHT Addict
 
Join Date: Jan 2008
Posts: 100
Not is working i have errors when i try to play many rules

Code:
RewriteRule ^/example/$    /example.html [L]
Code:
RewriteRule ^example$ /example.html [R=301,L]
Code:
RewriteRule ^example(.*) /example.html [R=301,L]
all this always return me this

[REWRITE] Rule: Match '/example' with pattern '^example$', result: -1
2009-03-28 18:11:43.479 [INFO] [x.x.x.x:2318-0#example] File not found [/home/user/example.net/example]

Of course there isn't folder called example and that is why i have 404 error.

Dunno it's webserver i'm using litespeed, i've read that the syntax are equals to apache and should not give problems.

Reply With Quote
Sponsored Links
  #4  
Old 03-29-2009, 03:01 AM
mwatkins mwatkins is offline
Web Hosting Master
 
Join Date: Nov 2001
Location: Vancouver
Posts: 2,416
Quote:
Originally Posted by Kurogane View Post
Of course there isn't folder called example and that is why i have 404 error.
That's not an issue, that's a feature and is in fact one of the main reasons for Rewrite in the first place -- you can have URL's that don't physically exist. The rewrite delivers the browser to the content.

Quote:
Dunno it's webserver i'm using litespeed, i've read that the syntax are equals to apache and should not give problems.
In the future if you want help with something you've got to learn how to ask *smart* questions. Should I or anyone else have to *guess* at what software you are running?

In the meantime, try the obvious first. The following DOES work in Apache.

Code:
RewriteEngine On
RewriteRule ^/example$         /example.html [L]

__________________
“Even those who arrange and design shrubberies are under
considerable economic stress at this period in history.”

Reply With Quote
Reply

Related posts from TheWhir.com
Title Type Date Posted
The Value of Your Intellectual Property Blog 2013-05-06 17:43:13
Joomla Hosting Study Shows Speed, Uptime Top Selling Points of a Web Host Web Hosting News 2012-11-07 15:06:36
Web Host WebHostForASP.net Launches VPS Hosting Service Web Hosting News 2012-06-29 14:52:22
Rackspace Blog Looks at Easy Outsourcing for App Development Blog 2012-03-05 19:07:48
Blackberry the UnCloud Blog 2011-10-14 15:28:54


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

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 Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?