Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > ISPConfig 2 > General

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 23rd June 2011, 23:15
Pasco Pasco is offline
Member
 
Join Date: Aug 2005
Location: Switzerland
Posts: 94
Thanks: 11
Thanked 0 Times in 0 Posts
Default How to create a rewritecond/rule

Hi 2gether

I have a file on my webserver, like:

www.domain.com/demo/demo.iso

Now I'd like to go every request for this link just to

www.domain.com/demo/index.html or just www.domain.com/demo

How can I do this with rewrite? I don't get it

RewriteEngine On
RewriteCond ?
RewriteRule ?

Thanks so much!
P@sco
Reply With Quote
Sponsored Links
  #2  
Old 24th June 2011, 01:11
slatz slatz is offline
Junior Member
 
Join Date: May 2011
Posts: 2
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Quote:
Originally Posted by Pasco View Post
www.domain.com/demo/demo.iso

Now I'd like to go every request for this link just to

www.domain.com/demo/index.html or just www.domain.com/demo
try this in your .htaccess file....

Redirect 301 /demo/demo.iso http://www.domain.com/demo
Reply With Quote
The Following User Says Thank You to slatz For This Useful Post:
Pasco (24th June 2011)
  #3  
Old 24th June 2011, 07:22
Pasco Pasco is offline
Member
 
Join Date: Aug 2005
Location: Switzerland
Posts: 94
Thanks: 11
Thanked 0 Times in 0 Posts
Default

works perfectly - thanks!

Just for my understanding: I could have done that with mod_rewrite too?

Cheers, p@sco
Reply With Quote
  #4  
Old 24th June 2011, 15:38
slatz slatz is offline
Junior Member
 
Join Date: May 2011
Posts: 2
Thanks: 0
Thanked 2 Times in 2 Posts
 
Default

Quote:
Originally Posted by Pasco View Post
works perfectly - thanks!

Just for my understanding: I could have done that with mod_rewrite too?

Cheers, p@sco
yeah you could have, something like this:

RewriteEngine on
RewriteRule ^demo\demo.iso$ demo.html


The caret, ^, signifies the start of an URL, under the current directory. This directory is whatever directory the .htaccess file is in. Youíll start almost all matches with a caret.

The dollar sign, $, signifies the end of the string to be matched. You should add this in to stop your rules matching the first part of longer URLs.

The period or dot before the file extension is a special character in regular expressions, and would mean something special if we didnít escape it with the backslash, which tells Apache to treat it as a normal character.

So, this rule will make your server transparently redirect from demo\demo.iso to the demo.html page. Your reader will have no idea that it happened, and itís pretty much instantaneous.

NOTE: RewriteEngine on (only needs to be specified once in your .htaccess file).
Reply With Quote
The Following User Says Thank You to slatz For This Useful Post:
createch (3rd July 2011)
Reply

Bookmarks

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Postfix doesn't have Nolan Installation/Configuration 5 13th April 2011 05:00
cannot create new ssh users for one client wildnux Server Operation 0 9th February 2011 01:10
Cron Jobs Nolan Installation/Configuration 1 17th December 2010 23:37
Chroot SSH + ISPConfig Norman Installation/Configuration 27 26th March 2007 03:40
Chrooted SSH apps bkrausz Tips/Tricks/Mods 14 29th August 2006 23:32


All times are GMT +2. The time now is 07:12.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.