You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by James Moe <ji...@sohnen-moe.com> on 2015/06/28 22:02:44 UTC

[users@httpd] mod_rewrite is ignored or disabled

Hello,
  httpd v2.4.10
  linux v3.16.7-21-desktop x86_64

  I am consolidating a discussion started in message "ReDirect
question". The issue there is that mod_rewrite is simply ignored.
Below are the contents of .htaccess and vhost.
  In both .htaccess and vhost the Rewrite* directive are simply
ignored as though they are commented out. (If I make a syntax error,
"Internal Server Error" occurs. Otherwise, nothing.) On our public
site which is running httpd v2.2, both rewrites perform as expected.
  Kurtis Rader and Eric Covener have patiently made a number of
suggestions to diagnose the problem. No joy, yet.

  What I am doing: We are moving our business suite to a new service
and we are using their shopping cart. The rewrites will point existing
category and specific product URLs to corresponding locations at the
new site based on the query string.

----[ .htaccess ]----
#
Options +ExecCGI +FollowSymLinks
#  Specific redirects first, then fallback
#
RewriteEngine on
RewriteCond %{QUERY_STRING} =app=ecom&ns=catshow&ref=books
RewriteRule ^
https://ya250.infusionsoft.com/app/storeFront/handleStoreFrontLink?displayType=Category&id=1&displayName=Books
[R=301]
#
RewriteEngine off
#
# The fallback. Will be changed to point to ya250.... later.
Redirect /catalog/ https://sma-v3.sma.com/clickcart/
#
----[ end ]----

----[ vhost ]----
# 20100606: Local copy of the sohnen-moe.com Version 3 site
#
<VirtualHost *:80>
    ServerAdmin jimoe@sohnen-moe.com

    ServerName sma-v3.sma.com
    DocumentRoot "/data01/t-drv/websites/sma-v3"
    ErrorDocument 404 /404.php
    ErrorDocument 410 /410.php
    ErrorDocument 401 /401.php

    ErrorLog  "/data01/t-drv/websites/.logs/sma-v3-error_log"
    CustomLog "/data01/t-drv/websites/.logs/sma-v3-access_log" common

 <Directory "/data01/t-drv/websites/sma-v3">
    AllowOverride FileInfo Authconfig Options
    Options Indexes FollowSymLinks MultiViews

    AddHandler application/x-httpd-php .php
    MultiviewsMatch Handlers

    Order allow,deny
    Allow from all

    AllowOverride All
#
# Always use a secure connection (at SMA site, this is in .htaccess)
    RewriteEngine On
    RewriteCond %{SERVER_PORT} =80
    RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R,L]
 </Directory>
 <Files *>
   Forcetype application/x-http-php
 </Files>
 <Files *\.*>
   Forcetype none
 </Files>

</VirtualHost>

##
## SSL Virtual Host Context
##
<IfDefine SSL>
#
#   Some MIME-types for downloading Certificates and CRLs
#
  AddType application/x-x509-ca-cert .crt
  AddType application/x-pkcs7-crl    .crl

<IfModule mod_ssl.c>
<VirtualHost *:443>

#  General setup for the virtual host
  DocumentRoot "/data01/t-drv/websites/sma-v3"
  ServerName sma-v3.sma.com
  ServerAdmin jimoe@sohnen-moe.com
  ErrorLog  "/data01/t-drv/websites/.logs/sma-v3s-error_log"
  CustomLog "/data01/t-drv/websites/.logs/sma-v3s-access_log" common
  TransferLog "/data01/t-drv/websites/.logs/access_log"

  ErrorDocument 404 /404.php
  ErrorDocument 410 /410.php
  ErrorDocument 401 /401.php

 <Directory "/data01/t-drv/websites/sma-v3">
    AllowOverride Authconfig
    AllowOverride All
    Options -ExecCGI
 </Directory>

 SSLEngine on

 SSLCertificateFile "/data01/t-drv/websites/.conf/ssl/sma-v3-site.crt"
 SSLCertificateKeyFile
"/data01/t-drv/websites/.conf/ssl/sma-v3-site.key.pem"

 SSLCipherSuite HIGH:!SSLv2:!ADH:!aNULL:!eNULL:!NULL
 SSLProtocol ALL -SSLv2

 SetEnvIf User-Agent ".*MSIE.*" \
         nokeepalive ssl-unclean-shutdown \
         downgrade-1.0 force-response-1.0

</VirtualHost>
</ifmodule>
</ifdefine>

----[ end ]----



-- 
James Moe
moe dot james at sohnen-moe dot com
520.743.3936


Re: [users@httpd] mod_rewrite is ignored or disabled

Posted by James Moe <ji...@sohnen-moe.com>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 06/29/2015 02:08 AM, Zimmi wrote:
> I would say the problem now is that your rewrite in .htaccess
> *overrides *the rewrite in the Directory section of the VHost.
> 
  Yes, that was it. You are very sharp. Thank you!
  I moved the rewrite from vhost to .htaccess; it all works great.
> 
> (sorry for last top-post, I'm a mailing list beginner)
> 
  Well.... Okay. I'll let it slide this time.
  Please consider trimming your posts as well. Reproducing header and
footers is quite unnecessary, and makes the post more difficult to read.

- -- 
James Moe
moe dot james at sohnen-moe dot com
520.743.3936
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iEYEARECAAYFAlWRgasACgkQzTcr8Prq0ZPWUACgoNbqlo9s30vsZKH2UXJxE1vj
VywAn2EXhM4DpcZhaHeYOSiXIacEq0Qu
=qpuG
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] mod_rewrite is ignored or disabled

Posted by Zimmi <zi...@gmail.com>.
Le 29.06.2015 03:18, James Moe a écrit :
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 06/28/2015 03:02 PM, Zimmi wrote:
>> There are in your .htaccess file 2 instructions "RewriteEngine":
>> the first states "on", the second states "off". They are around
>> your rewrite rules, so I try to guess that  you meant to switch the
>> rewrite engine on, do the rewrite, and then switch it off.
>>
>    Yes, that was the idea.
>
>> But, afaik the last instruction wins and disables the rewrite
>> engine: no action and no logging... Remove the second one or
>> comment it, and let us know.
>>
>    Whoo-hoo! The rewrite in .htaccess works.
>    The one in vhosts does not. :-( I removed the "L" flag; it made no
> difference.
>
> - -- 
> James Moe
> moe dot james at sohnen-moe dot com
> 520.743.3936
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v2
>
> iEYEARECAAYFAlWQnPcACgkQzTcr8Prq0ZMi3QCghBO8Amz6lH7wjt+CiI2d6dU5
> nwMAn1wjttdXJfG2dGUxl49GIsi1qX5c
> =h/PU
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>
Hi,

Alright, then it seems we have the first step !

I would say the problem now is that your rewrite in .htaccess *overrides 
*the rewrite in the Directory section of the VHost. See:
https://httpd.apache.org/docs/2.4/en/sections.html#merging

While testing a very similar situation some months ago (but with v.2.2), 
I've noticed that it is not enough to set "RewriteEngine Off" in 
.htaccess , as this will still override all the rules in VHost Directory 
configuration section. You need to completely remove or comment out all 
mod_rewrite instructions in your .htaccess in order to have the ones in 
the VHost Directory section to be applied.

First and simplest thing to try is to put all your rewrite instructions 
in the same container : all in .htaccess or all in VHost Directory 
section (if you chose VHost Directory section, remember to 
remove/comment out *all *instructions from mod_rewrite in the .htaccess 
file).

Later, as from your comment in your VHost config, you want everything 
with SSL, have a look at this page too:
https://wiki.apache.org/httpd/RedirectSSL

You could also try that solution with Redirect for the redirect to SSL, 
and then put all your config in the ssl VHost configuration.

(sorry for last top-post, I'm a mailing list beginner)

Zimmi


Re: [users@httpd] mod_rewrite is ignored or disabled

Posted by James Moe <ji...@sohnen-moe.com>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 06/28/2015 03:02 PM, Zimmi wrote:
> There are in your .htaccess file 2 instructions "RewriteEngine":
> the first states "on", the second states "off". They are around
> your rewrite rules, so I try to guess that  you meant to switch the
> rewrite engine on, do the rewrite, and then switch it off.
> 
  Yes, that was the idea.

> But, afaik the last instruction wins and disables the rewrite
> engine: no action and no logging... Remove the second one or
> comment it, and let us know.
> 
  Whoo-hoo! The rewrite in .htaccess works.
  The one in vhosts does not. :-( I removed the "L" flag; it made no
difference.

- -- 
James Moe
moe dot james at sohnen-moe dot com
520.743.3936
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iEYEARECAAYFAlWQnPcACgkQzTcr8Prq0ZMi3QCghBO8Amz6lH7wjt+CiI2d6dU5
nwMAn1wjttdXJfG2dGUxl49GIsi1qX5c
=h/PU
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] mod_rewrite is ignored or disabled

Posted by Kurtis Rader <kr...@skepticism.us>.
On Sun, Jun 28, 2015 at 3:02 PM, Zimmi <zi...@gmail.com> wrote:

> There are in your .htaccess file 2 instructions "RewriteEngine": the first
> states "on", the second states "off". They are around your rewrite rules,
> so I try to guess that  you meant to switch the rewrite engine on, do the
> rewrite, and then switch it off. But, afaik the last instruction wins and
> disables the rewrite engine: no action and no logging...
> Remove the second one or comment it, and let us know.


 Argh! I was helping James in the earlier thread and should have caught
that.

James, keep in mind that in a given context (e.g., a .htaccess file) all of
the directives are parsed and processed before being applied to the current
request. So, as Zimmi points out, having more than one RewriteEngine
doesn't make any sense. The same is true for RewriteBase.

-- 
Kurtis Rader
Caretaker of the exceptional canines Junior and Hank

Re: [users@httpd] mod_rewrite is ignored or disabled

Posted by Zimmi <zi...@gmail.com>.
Hi,
There are in your .htaccess file 2 instructions "RewriteEngine": the 
first states "on", the second states "off". They are around your rewrite 
rules, so I try to guess that  you meant to switch the rewrite engine 
on, do the rewrite, and then switch it off. But, afaik the last 
instruction wins and disables the rewrite engine: no action and no 
logging...
Remove the second one or comment it, and let us know.

Hope this helps,
Zimmi (Philippe)

Le 28.06.2015 22:02, James Moe a écrit :
> Hello,
>    httpd v2.4.10
>    linux v3.16.7-21-desktop x86_64
>
>    I am consolidating a discussion started in message "ReDirect
> question". The issue there is that mod_rewrite is simply ignored.
> Below are the contents of .htaccess and vhost.
>    In both .htaccess and vhost the Rewrite* directive are simply
> ignored as though they are commented out. (If I make a syntax error,
> "Internal Server Error" occurs. Otherwise, nothing.) On our public
> site which is running httpd v2.2, both rewrites perform as expected.
>    Kurtis Rader and Eric Covener have patiently made a number of
> suggestions to diagnose the problem. No joy, yet.
>
>    What I am doing: We are moving our business suite to a new service
> and we are using their shopping cart. The rewrites will point existing
> category and specific product URLs to corresponding locations at the
> new site based on the query string.
>
> ----[ .htaccess ]----
> #
> Options +ExecCGI +FollowSymLinks
> #  Specific redirects first, then fallback
> #
> RewriteEngine on
> RewriteCond %{QUERY_STRING} =app=ecom&ns=catshow&ref=books
> RewriteRule ^
> https://ya250.infusionsoft.com/app/storeFront/handleStoreFrontLink?displayType=Category&id=1&displayName=Books
> [R=301]
> #
> RewriteEngine off
> #
> # The fallback. Will be changed to point to ya250.... later.
> Redirect /catalog/ https://sma-v3.sma.com/clickcart/
> #
> ----[ end ]----
>
> ----[ vhost ]----
> # 20100606: Local copy of the sohnen-moe.com Version 3 site
> #
> <VirtualHost *:80>
>      ServerAdmin jimoe@sohnen-moe.com
>
>      ServerName sma-v3.sma.com
>      DocumentRoot "/data01/t-drv/websites/sma-v3"
>      ErrorDocument 404 /404.php
>      ErrorDocument 410 /410.php
>      ErrorDocument 401 /401.php
>
>      ErrorLog  "/data01/t-drv/websites/.logs/sma-v3-error_log"
>      CustomLog "/data01/t-drv/websites/.logs/sma-v3-access_log" common
>
>   <Directory "/data01/t-drv/websites/sma-v3">
>      AllowOverride FileInfo Authconfig Options
>      Options Indexes FollowSymLinks MultiViews
>
>      AddHandler application/x-httpd-php .php
>      MultiviewsMatch Handlers
>
>      Order allow,deny
>      Allow from all
>
>      AllowOverride All
> #
> # Always use a secure connection (at SMA site, this is in .htaccess)
>      RewriteEngine On
>      RewriteCond %{SERVER_PORT} =80
>      RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R,L]
>   </Directory>
>   <Files *>
>     Forcetype application/x-http-php
>   </Files>
>   <Files *\.*>
>     Forcetype none
>   </Files>
>
> </VirtualHost>
>
> ##
> ## SSL Virtual Host Context
> ##
> <IfDefine SSL>
> #
> #   Some MIME-types for downloading Certificates and CRLs
> #
>    AddType application/x-x509-ca-cert .crt
>    AddType application/x-pkcs7-crl    .crl
>
> <IfModule mod_ssl.c>
> <VirtualHost *:443>
>
> #  General setup for the virtual host
>    DocumentRoot "/data01/t-drv/websites/sma-v3"
>    ServerName sma-v3.sma.com
>    ServerAdmin jimoe@sohnen-moe.com
>    ErrorLog  "/data01/t-drv/websites/.logs/sma-v3s-error_log"
>    CustomLog "/data01/t-drv/websites/.logs/sma-v3s-access_log" common
>    TransferLog "/data01/t-drv/websites/.logs/access_log"
>
>    ErrorDocument 404 /404.php
>    ErrorDocument 410 /410.php
>    ErrorDocument 401 /401.php
>
>   <Directory "/data01/t-drv/websites/sma-v3">
>      AllowOverride Authconfig
>      AllowOverride All
>      Options -ExecCGI
>   </Directory>
>
>   SSLEngine on
>
>   SSLCertificateFile "/data01/t-drv/websites/.conf/ssl/sma-v3-site.crt"
>   SSLCertificateKeyFile
> "/data01/t-drv/websites/.conf/ssl/sma-v3-site.key.pem"
>
>   SSLCipherSuite HIGH:!SSLv2:!ADH:!aNULL:!eNULL:!NULL
>   SSLProtocol ALL -SSLv2
>
>   SetEnvIf User-Agent ".*MSIE.*" \
>           nokeepalive ssl-unclean-shutdown \
>           downgrade-1.0 force-response-1.0
>
> </VirtualHost>
> </ifmodule>
> </ifdefine>
>
> ----[ end ]----
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org