Re: Apache and RewriteRule

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I turn this on when I'm debugging Rewrite rules:
# Apache 2.4 - rewrite debug - trace0:trace8
       RewriteLog      /var/log/httpd/rewrite.log
       LogLevel        rewrite:trace4

Bill

On 3/1/2019 10:08 PM, Todd Zullinger wrote:
Hi,

Alex wrote:
I believe you want to use something like:

    RewriteCond %{QUERY_STRING} ^option=login$
    RewriteRule ^/index.php?$   /register       [R=301,L]

It's been a while since I've done this, so I'm not sure
whether the "?" after index.php is matched.  You may need to
adjust that pattern.
I would expect to not want the "?" in the RewriteRule; it should be
stripped by the process which breaking things into the path and the
query_string. Untested opinion, it has been a while for me too.
Yep.  I saw some suggestions with the trailing '?' so I
included it in the example, since I wasn't sure either way.
It's not wanted or needed, now that I've tested.

And in principle you want to escape the ".": "\."
No doubt.  I tend to try and make any regexp's tightly
defined when I'm putting them into use.  Though making them
a bit loose to start can help to ensure that the rest of the
rule is hit.

Both with the ? and without didn't make a difference. It didn't work either way.

It seemed to ignore it entirely. It continued to report "component not
found", as if it's trying to process the option= portion.

If no one has any further ideas, perhaps you know of a better resource?

Of course I'm also happy to try other ideas...
I just tested locally.  Here's what worked for me:

    [tmz@f29 ~]$ cat /etc/httpd/conf.d/rewrite_test.conf
    <Directory /var/www/html>
        RewriteEngine on
        RewriteCond %{QUERY_STRING} ^option=login$
        RewriteRule ^index.php      /register       [R=301,L,QSD]
    </Directory>

    [tmz@f29 ~]$ curl -I 'localhost/index.php?option=login'
    HTTP/1.1 301 Moved Permanently
    Date: Sat, 02 Mar 2019 03:00:52 GMT
    Server: Apache/2.4.38 (Fedora)
    Location: http://localhost/register
    Content-Type: text/html; charset=iso-8859-1

The URI was matched without a leading /.  To strip the query
string, the QSD flag is handy.  That's in httpd >= 2.4.0.


_______________________________________________
users mailing list -- users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to users-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://getfedora.org/code-of-conduct.html
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/users@xxxxxxxxxxxxxxxxxxxxxxx
_______________________________________________
users mailing list -- users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to users-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://getfedora.org/code-of-conduct.html
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/users@xxxxxxxxxxxxxxxxxxxxxxx
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux