Welcome to MobyThreads.com!
FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in
All support for the MobyThreads Threaded phpBB MOD can now be found on welsolutions at this forum

Problems with mod_rewrite

 
   Web Hosting and Web Master Forums (Home) -> Apache RSS
Next:  Apache 2.0 with Subversion authenticate against A..  
Author Message
nobschlaakspam

External


Since: Oct 15, 2003
Posts: 6



(Msg. 1) Posted: Wed Oct 15, 2003 9:17 pm
Post subject: Problems with mod_rewrite
Archived from groups: alt>apache>configuration (more info?)

Hi out there!

I got a strange problem with my apache. For lots of weeks everything went
fine. But a few days ago I encountered some errors. The heaviest seems to be
that the mod_rewrite does not work properly ... and I've had a lot of work
to get it up and running ages ago. Sad

Perhaps it hangs because I rearranges my vhosts a few weeks ago - but I
don't think that these two things depend on eachother (?).

I don't know what to do, I tested several settings, but none of my
RewriteRules is executed. Perhaps some of you could briefly browse through
the snippets of my config files and give me one or more hint(s)? I would be
very glad ...

Thanks in advance!

Bjoern


Output from "apachectl fullstatus":
----- 8< -----
Server Version: Apache/1.3.19 (Unix) (SuSE/Linux) ApacheJServ/1.1.2
mod_layout/1.0 mod_throttle/3.0 mod_fastcgi/2.2.2 mod_ssl/2.8.3
OpenSSL/0.9.6a PHP/4.0.6 mod_perl/1.25 mod_dtcl
Server Built: Oct 21 2002 10:31:55

----- >8 -----

/etc/httpd/httpd.conf:
----- 8< -----
[...]

LoadModule rewrite_module /usr/lib/apache/mod_rewrite.so

[...]

AddModule mod_rewrite.c

[...]

<IfModule mod_rewrite.c>
RewriteEngine on

RewriteLog /var/log/httpd/rewrite_log
## Just for debugging - normally switched to "3"
RewriteLogLevel 7

## This is to redirect all requests searching for M$-related security
holes
## to the people who should handle them correctly ...
RewriteCond %{REQUEST_URI}root\.exe [NC,OR]
RewriteCond %{REQUEST_URI}cmd\.exe [NC,OR]
RewriteCond %{REQUEST_URI}default\.ida [NC]
RewriteRule ^/(.*)$ http://www.microsoft.com/$1?%{QUERY_STRING}
[R=301,L]

## If someone forgets the trailing /
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+[^/])$ $1/ [R]

## This is to read requests for pages without any subdomain from the
## correct directory
RewriteCond %{SERVER_NAME}^([^.]+)\.([^.]+)$ [NC]
RewriteRule ^/(.*)$ /www/%2/%1/htdocs/$1?%{QUERY_STRING}

## Every vhost on my machine should have a subdomain named "webmail"
## to reach the qmail webmail pages ... the following directives are
needed for this
RewriteCond %{SERVER_NAME}^webmail\..+ [NC]
RewriteRule ^/images/(.*)$ http://my.ip.add.ress/images/$1 [P,L]

RewriteCond %{SERVER_NAME}^webmail\..+ [NC]
RewriteRule ^/admin(.*)$
http://my.ip.add.ress/cgi-bin/qmailadmin$1?%{QUERY_STRING} [P,L]

RewriteCond %{SERVER_NAME} ^webmail\..+ [NC]
RewriteRule ^/(.*)$
http://my.ip.add.ress/cgi-bin/sqwebmail$1?%{QUERY_STRING} [P,L]
</IfModule>

[...]

<VirtualHost _default_:*>
ServerName my.servername.tld
ServerAdmin webmaster RemoveThis @servername.tld

DocumentRoot "/usr/local/httpd/htdocs"
ErrorLog /var/log/httpd/error_log
CustomLog /var/log/httpd/access_log combined

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteOptions inherit
</IfModule>
</VirtualHost>

Include /etc/httpd/vhost.conf

[...]
----- >8 -----

/etc/httpd/vhost.conf:
----- 8< -----
[...]

<VirtualHost my.ip.add.ress>
ServerName vhostdomain.tld
ServerAlias *.vhostdomain.tld
ServerAdmin webmaster RemoveThis @vhostdomain.tld

DocumentRoot "/usr/local/httpd/vhosts/tld/vhostdomain/www/htdocs"
VirtualDocumentRoot "/usr/local/httpd/vhosts/%-1/%-2/%-3+/htdocs"
ErrorLog "/usr/local/httpd/vhosts/tld/vhostdomain/error_log"
CustomLog "/usr/local/httpd/vhosts/tld/vhostdomain/access_log" combined

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteOptions inherit

## This rule should redirect requests like "/stuff/1.html" to
"/index.php?show=1"
## and something like "/stuff/more_info.html?some=vars&more=vars" to
## "/index.php?show=more_info&some=vars&more=vars" ... works
perfectly (local)
RewriteRule ^/stuff/(.+)\.html$
http://www.vhostdomain.tld/index.php?show=$1&%{QUERY_STRING} [P,L]

## And now a special case ... all this is to make my site more
search engine friendly
RewriteRule ^/pictures\.html$
http://www.vhostdomain.tld/index.php?menu=6&%{QUERY_STRING} [P,L]
</IfModule>
</VirtualHost>

[...]
----- >8 -----

 >> Stay informed about: Problems with mod_rewrite 
Back to top
Login to vote
spam3

External


Since: Jul 01, 2003
Posts: 411



(Msg. 2) Posted: Wed Oct 15, 2003 9:17 pm
Post subject: Re: Problems with mod_rewrite [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Björn Schlaak wrote:
 > the mod_rewrite does not work properly
 >
 > none of my
 > RewriteRules is executed.

Is it that they aren't executed, or don't do what you expect? Set up a
log file to determine this.

 > <IfModule mod_rewrite.c>
 > RewriteEngine on
 > RewriteOptions inherit

add a base statement like:
RewriteBase /

 > ## This rule should redirect requests like "/stuff/1.html" to
 > "/index.php?show=1"
 > ## and something like "/stuff/more_info.html?some=vars&more=vars" to
 > ## "/index.php?show=more_info&some=vars&more=vars" ... works
 > perfectly (local)
 > RewriteRule ^/stuff/(.+)\.html$
 > <a style='text-decoration: underline;' href="http://www.vhostdomain.tld/index.php?show=$1&%" target="_blank">http://www.vhostdomain.tld/index.php?show=$1&%</a>{QUERY_STRING} [P,L]

Remove the / after the ^ anchor. When the request comes in, mod_rewrite
will see it without the leading slash - at least that's the way it's
been working for me. Also, if you aren't redirecting to a different
domain (or using mod_proxy), don't bother putting that in.
&%{QUERY_STRING} can be done with a rewrite flag, QSA:

RewriteRule ^stuff/(.+)\.html$ index.php?show=$1 [L,QSA]

 > ## And now a special case ... all this is to make my site more
 > search engine friendly
 > RewriteRule ^/pictures\.html$
 > <a style='text-decoration: underline;' href="http://www.vhostdomain.tld/index.php?menu=6&%" target="_blank">http://www.vhostdomain.tld/index.php?menu=6&%</a>{QUERY_STRING} [P,L]

Same thing here:
RewriteRule ^pictures\.html$ index.php?menu=6 [L,QSA]

HTH

--
Justin Koivisto - spam DeleteThis @koivi.com
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended.<!-- ~MESSAGE_AFTER~ -->

 >> Stay informed about: Problems with mod_rewrite 
Back to top
Login to vote
nobschlaakspam

External


Since: Oct 15, 2003
Posts: 6



(Msg. 3) Posted: Wed Oct 15, 2003 10:51 pm
Post subject: Re: Problems with mod_rewrite [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Hi,

"Justin Koivisto" <spam RemoveThis @koivi.com> schrieb im Newsbeitrag
news:nBfjb.1654$ow5.65495@news7.onvoy.net...
  > > none of my
  > > RewriteRules is executed.
 >
 > Is it that they aren't executed, or don't do what you expect? Set up a
 > log file to determine this.

Oh, I wanted to add my RewriteLog - but there's nothing in it except those
entries that come from requests without any hostname. The RewriteRules
simply aren't executed if the request should be handled by one of my vhosts.
It seem's like the whole mod_rewrite does not work. But it did before - and
I changed nothing except my vhost handling. I wonder if that has any effect
to "global" RewriteRules(?).

 > add a base statement like:
 > RewriteBase /

 > RewriteRule ^stuff/(.+)\.html$ index.php?show=$1 [L,QSA]

 > RewriteRule ^pictures\.html$ index.php?menu=6 [L,QSA]

As I wrote, the rules work perfectly on my desktop PC - so there's nothing
wrong with their syntax. I'll try your proposals - but I don't think that
thas will have any effect on the main problem.


 > HTH

Thanks anyway.

Bjoern<!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: Problems with mod_rewrite 
Back to top
Login to vote
spam3

External


Since: Jul 01, 2003
Posts: 411



(Msg. 4) Posted: Wed Oct 15, 2003 10:51 pm
Post subject: Re: Problems with mod_rewrite [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Björn Schlaak wrote:
 > "Justin Koivisto" <spam.DeleteThis@koivi.com> schrieb im Newsbeitrag
 > news:nBfjb.1654$ow5.65495@news7.onvoy.net...
 >
   >>>none of my RewriteRules is executed.
  >>
  >>Is it that they aren't executed, or don't do what you expect? Set up a
  >>log file to determine this.
 >
 > Oh, I wanted to add my RewriteLog - but there's nothing in it except those
 > entries that come from requests without any hostname. The RewriteRules
 > simply aren't executed if the request should be handled by one of my vhosts.

Set up a separate rewrite log file for each vhost, it will make things
much easier to track down instead of one file that handles all the
domains. As far as disk space, that's only one extra inode per file
since the data that's written will be the same, just a different
location. (ext2 filesystem inode has a default of 4K, so 256 files would
be 1MB)

 > It seem's like the whole mod_rewrite does not work. But it did before - and
 > I changed nothing except my vhost handling. I wonder if that has any effect
 > to "global" RewriteRules(?).

Usually the way I handle rewrite is to put all the rules specific to a
domain in a .htaccess file in the document root rather than in the
virtualhost container. However, most of my code goes to different
servers where I don't have access to edit httpd.conf...

  >>add a base statement like:
  >>RewriteBase /
  >>RewriteRule ^stuff/(.+)\.html$ index.php?show=$1 [L,QSA]
  >>RewriteRule ^pictures\.html$ index.php?menu=6 [L,QSA]
 >
 > As I wrote, the rules work perfectly on my desktop PC - so there's nothing
 > wrong with their syntax. I'll try your proposals - but I don't think that
 > thas will have any effect on the main problem.

The point was that if you aren't using mod_proxy, then why use the [P]
flag if it doesn't do anything - it's just more resources being used.
manually appending the QUERY_STRING is the same thing, the flag takes
less resources to use than "&%{QUERY_STRING}" at the end of a rule.

If rewrite isn't executing the requests, then it would seem that the
<IfModule mod_rewrite.c> contents aren't being included for the host.
That is another reason I put the stuff in the .htaccess file. If rewrite
isn't enabled on the server, when the "RewriteEngine On" line is parsed,
I get a nice 500 error (never thought I'd say that) indicating that the
setup isn't correct. I'd assume the same would hold true in the virthost
containers if you removed the <IfModule mod_rewrite.c> and </IfModule>
from the declaration.

Also, unless your desktop PC is configured the same exact way (OS
included), there isn't a guarantee that everything will work on both.
I've learned that over the years through many headaches. Most of the
time I do testing and devel on a Windows machine running apache and PHP,
but 99% of the time, the end result goes onto a *nix machine. I keep my
test config as close as possible to the production machine, but that
still doesn't rid all the headaches.

--
Justin Koivisto - spam.DeleteThis@koivi.com
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended.<!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: Problems with mod_rewrite 
Back to top
Login to vote
nobschlaakspam

External


Since: Oct 15, 2003
Posts: 6



(Msg. 5) Posted: Thu Oct 16, 2003 12:09 am
Post subject: Re: Problems with mod_rewrite [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

 > Usually the way I handle rewrite is to put all the rules specific
 > to a domain in a .htaccess file in the document root rather than
 > in the virtualhost container. However, most of my code goes to
 > different servers where I don't have access to edit httpd.conf...

RewriteRules in a .htaccess file need AFAIK more resources. And
because I have access to the httpd.conf, I did it this way to speed
up performance.


 > The point was that if you aren't using mod_proxy, then why use the
 > [P] flag if it doesn't do anything - it's just more resources
 > being used. manually appending the QUERY_STRING is the same thing,
 > the flag takes less resources to use than "&%{QUERY_STRING}" at
 > the end of a rule.

OK, I understand that. Thank you for this clue, I' try it. But
unfortunately it's not my problem. My problem is that the
RewriteRules just work only when I access the machine through its IP
address. When I try to get pages from one of the virtual hosts (from
the default vhost too) then they aren't executed.


 > Also, unless your desktop PC is configured the same exact way (OS
 > included), there isn't a guarantee that everything will work on
 > both. I've learned that over the years through many headaches.
 > Most of the time I do testing and devel on a Windows machine
 > running apache and PHP, but 99% of the time, the end result goes
 > onto a *nix machine. I keep my test config as close as possible to
 > the production machine, but that still doesn't rid all the
 > headaches.

My desktop is not exactly the same like the server (shouldn't be, am
I right?). And - as I wrote - everything went fine (and I guess that
seems to be a clue that there's nothing essential wrong with my
mod_rewrite stuff) until a few days ago when I changed my vhost
management. So I think that the problem must be somewhere there -
although I just can't believe that these two different mods depend on
eachother.

So, if anyone could give me a hint, encountered the same or similar
problems or just has THE IDEA ... please contact me!


Bjoern

-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBP42bY0oxrztrEACREQIuFQCgxL4xgS8Gf5MkBR0BffPr6aXiPPgAoPqy
QPeLEgx26CqaOLqjJBQ2jriT
=+F64
-----END PGP SIGNATURE-----<!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: Problems with mod_rewrite 
Back to top
Login to vote
spam3

External


Since: Jul 01, 2003
Posts: 411



(Msg. 6) Posted: Thu Oct 16, 2003 12:09 am
Post subject: Re: Problems with mod_rewrite [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Björn Schlaak wrote:
 > My problem is that the
 > RewriteRules just work only when I access the machine through its IP
 > address. When I try to get pages from one of the virtual hosts (from
 > the default vhost too) then they aren't executed.

It almost sounds like there are 2 copies of the sites then. Firstly,
resolve the server name to an IP address and compare with what you think
it *should* be.

For instnace, on my server, I do this:
$ resolveip <a style='text-decoration: underline;' href="http://www.wafisherinteractive.com" target="_blank">www.wafisherinteractive.com</a>
IP address of <a style='text-decoration: underline;' href="http://www.wafisherinteractive.com" target="_blank">www.wafisherinteractive.com</a> is 206.146.208.20

If the IP address that is returned isn't what you're expecting, then you
have a DNS issue (likely for the www A record or an entry in your
workstation's hosts file).

If the IP address is correcy and works for the domains, but the name
doesn't, check to make sure that both requests are logging into the same
access_log file (if you have separate log files defined for each virtual
host).

If all this is working as expected, then I don't know where to look
next. Hope some of what I have said today will help!

--
Justin Koivisto - spam.RemoveThis@koivi.com
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended.<!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: Problems with mod_rewrite 
Back to top
Login to vote
nobschlaakspam

External


Since: Oct 15, 2003
Posts: 6



(Msg. 7) Posted: Thu Oct 16, 2003 12:41 am
Post subject: Re: Problems with mod_rewrite [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Hi,

 > It almost sounds like there are 2 copies of the sites then. Firstly,
 > resolve the server name to an IP address and compare with what you think
 > it *should* be.

That's not the problem. There were no changes to the DNS and all the vhost
domains resolve correctly. It's simply just a problem with the mod_rewrite
(and perhaps the vhosts) ... and I don't know what exactly is wrong because
I changed nothing regarding the mod_rewrite ... Sad


 > If the IP address is correcy and works for the domains, but the name
 > doesn't, check to make sure that both requests are logging into the same
 > access_log file (if you have separate log files defined for each virtual
 > host).

Why should they log into the same file? The problem is that the
rewrite-stuff does not work if one of my vhosts is requested for data. If
the requests go to my "naked" IP address, then everything works fine.


 > If all this is working as expected, then I don't know where to look
 > next. Hope some of what I have said today will help!

Unfortunately not really. But thanks anyway ...


Bjoern<!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: Problems with mod_rewrite 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Problems with SSI - Hi, I've just setup my apache server 2.0.43 for SSI. The SSI Commands for my shtml pages are working fine. In my HTML-page there are the following lines: <!--#exec cgi="redirect.pl" --> this works. <!--#exec cgi="redirect.pl?n...

Problems with SSI - Hello, I'm using apache2.0.43 and want to enable the SSI feature for my server. I've done the following as described but nothing has changed in the output and I see the SSI-Tag. What can I do?? ---- httpd.conf ---- ServerName 127.0.0.1:80..

Install problems - This is my first attempt at Apache; I downloaded 2.047. That part went fine. My system is Windows 98, and I will be using Apache on my machine only as a localhost web server. When I begin the install, I'm prompted for "Network Domain" and &qu...

auth_mysql problems - I am trying to use auth_mysql 1.10 with apache 2.0.40 on redhat8.0. I had redhat update install it for me as that usually works but hardly any of the authmysql directives work in the .htaccess file and none of them work in httpd.conf. I have been tryin...

connection refused - ssl problems - Hi there, I just installed apache with modssl (apache was working prior to this without ssl) After starting I do get follosing msg: /usr/local/apache/bin/apachectl startssl: httpd started So this looks fine, however.. If I try to access a file like:....
   Web Hosting and Web Master Forums (Home) -> Apache All times are: Pacific Time (US & Canada) (change)
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 ]