Welcome to HostingForumz.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

rewrite_mod troubles

 
   Web Hosting Problem Solving Community! (Home) -> Apache RSS
Next:  PUT Method Not Allowed ?  
Author Message
redalert

External


Since: Jun 11, 2004
Posts: 2



(Msg. 1) Posted: Fri Jun 11, 2004 6:08 am
Post subject: rewrite_mod troubles
Archived from groups: alt>apache>configuration (more info?)

Hello, I have the following lines in my .htaccess file:

RewriteEngine On
RewriteRule ^(.*)\.htm /cgi-bin/viewpage.cgi?page=$1 [L]

The above rewrites all .htm file requests to a program that dynamically puts
the pages together. The trouble is if someone addresses the index web page
such as http://www.wakproductions.com/ without specifying a *.htm file.
That request will not rewrite as "index.htm"... how can I also get the
default file to be rerouted to "viewpage.cgi?page=index"?

Thanks.

WAK

 >> Stay informed about: rewrite_mod troubles 
Back to top
Login to vote
purlgurl

External


Since: Oct 24, 2003
Posts: 127



(Msg. 2) Posted: Fri Jun 11, 2004 6:08 am
Post subject: Re: rewrite_mod troubles [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Winston Kotzan wrote:

(snipped)

 > RewriteEngine On
 > RewriteRule ^(.*)\.htm /cgi-bin/viewpage.cgi?page=$1 [L]

 > The trouble is if someone addresses the index web page such as
 > <a rel="nofollow" style='text-decoration: none;' href="http://www.wakproductions.com/" target="_blank">http://www.wakproductions.com/</a> without specifying a *.htm file.
 > That request will not rewrite as "index.htm"...


RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^.*$ /cgi-bin/viewpage.cgi?page=index [L]

Play around with your REGEX for different effects.

You will discover writing verbose rules first, test,
then use shortcut methods, will make your task easier.

Note in your example REGEX $1 will contain "everything"
in the path before your \.htm ending.

^.*(index)\.htm$

That example will set $1 to a value of "index" as intended.


Purl Gurl
--
Rock Midis! Science Fiction! Amazing Androids!
<a rel="nofollow" style='text-decoration: none;' href="http://www.purlgurl.net/~callgirl/" target="_blank">http://www.purlgurl.net/~callgirl/</a>

 >> Stay informed about: rewrite_mod troubles 
Back to top
Login to vote
spam3

External


Since: Jul 01, 2003
Posts: 411



(Msg. 3) Posted: Fri Jun 11, 2004 4:16 pm
Post subject: Re: rewrite_mod troubles [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Winston Kotzan wrote:

 > Hello, I have the following lines in my .htaccess file:
 >
 > RewriteEngine On
 > RewriteRule ^(.*)\.htm /cgi-bin/viewpage.cgi?page=$1 [L]
 >
 > The above rewrites all .htm file requests to a program that dynamically puts
 > the pages together. The trouble is if someone addresses the index web page
 > such as <a rel="nofollow" style='text-decoration: none;' href="http://www.wakproductions.com/" target="_blank">http://www.wakproductions.com/</a> without specifying a *.htm file.
 > That request will not rewrite as "index.htm"... how can I also get the
 > default file to be rerouted to "viewpage.cgi?page=index"?

RewriteRule ^$ /cgi-bin/viewpage.cgi?page=index [L]

That will change <a rel="nofollow" style='text-decoration: none;' href="http://www.wakproductions.com/" target="_blank">http://www.wakproductions.com/</a> to
<a rel="nofollow" style='text-decoration: none;' href="http://www.wakproductions.com/cgi-bin/viewpage.cgi?page=index" target="_blank">http://www.wakproductions.com/cgi-bin/viewpage.cgi?page=index</a>

Also, your above pattern will transpose .html as well as .htm - don't
know if that is what you want, but thought that you may want to know
about that functionality. To only do .htm requests:

RewriteRule ^(.*)\.htm$ /cgi-bin/viewpage.cgi?page=$1 [L]
^
|
----------------------+

--
Justin Koivisto - spam.DeleteThis@koivi.com
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended.
 >> Stay informed about: rewrite_mod troubles 
Back to top
Login to vote
redalert

External


Since: Jun 11, 2004
Posts: 2



(Msg. 4) Posted: Sun Jun 13, 2004 3:21 am
Post subject: Re: rewrite_mod troubles [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Back to top
Login to vote
Display posts from previous:   
Related Topics:
SetEnvIf troubles - I'm trying to avoid having to create single line entries in my config for files that I don't want to log, but I'm having a bit of trouble getting there. If I use this entry below, it gets ignored and all the files in that folder get logged SetEnvIf..

VirtualHost troubles - I've got some problems setting up VH on a new debian (woody) test environment. Apache version in 1.3.26. Here are the starting situation: - ServerName set to localhost in httpd.conf - NameVirtualHost is set to localhost (A) (first attempt) or 127.0.0.1....

TSW webserving package ,troubles with virtualhosting.. - what ever i do ,i cant get virtual hosting running again.. all the path's are correct ,the directory structure is correct it always says Warning: DocumentRoot [/htdocs/] does not exist [Thu Jun 24 18:10:27 2004] [error] VirtualHost _default_:443 --..

Moving .htaccess commands to httpd.conf give troubles. - Hello. I want to make password access to a directory (Linux Apache http server 2.0). If i create a .htaccess file in /var/www/html/private it works fine. But the Apache homepage tells to avoid that and move it to the httpd.conf (see link:..

Hotlinking - I have a free site on royalfreehost.com and I wanted to use some of the images on another site - which is hosted on a pay site - by using hotlinking (to reduce bandwidth, ok, I know it's naughty!) It worked at first. After a few days it stopped ..
   Web Hosting Problem Solving Community! (Home) -> Apache All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]