Re: RewriteMap questions

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

 



On 5/31/07, Josh Trutwin <josh@xxxxxxxxxxxxxxxxxxx> wrote:
On Thu, 31 May 2007 13:20:03 -0400
"Joshua Slive" <joshua@xxxxxxxx> wrote:

> Yes, but I was thinking of having your script just output the
> /custom/404.php directly.

Hoping this is my last question - I have the following .htaccess file:

RewriteEngine On

# Rewrite Map for Page Rewrites

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* ${smc_rewriter:%{REQUEST_FILENAME}^%{REQUEST_URI}}
[L,QSA]

# Rewrite Map for old URL Redirects

ReWriteCond %{REQUEST_FILENAME} sitepages/p.*.php$
ReWriteCond %{QUERY_STRING} !redirect_to_new_url=yes
ReWriteRule .*
${smc_rewriter:%{REQUEST_FILENAME}^%{REQUEST_URI}}?redirect_to_new_url=yes
[R=301]

The first block works well to rewrite URL's from a mapping program -
e.g.:

new_page_name.php => sitepages/pid123.php

The second block is designed to send a 301 redirect to anyone that
uses the old URL's (maybe via a bookmark or search result) which I
also added to the map - this is supposed to redirect:

sitepages/pid123.php => new_page_name.php?redirect_to_new_url=yes

The query string bit is to avoid a loop.

That piece works ok, but when I added this block, the first part now
doesn't stop despite the [L] flag, it rewrites the new url to
sitepages/pid123.php then the next block gets executed then the first
one again, each request like this calls the program 3 times.

I can't tell at all what you are trying to accomplish here. Given you
have the second set of rules, why is the first set of rules necessary
at all? If people are redirected to the correct place, why do you then
need to remap internally?

Your problem with the [L] not working likely has to do with operating
in .htaccess files instead of the main server config. mod_rewrite
needs to reinject the request in order to make sure all the proper
rules are applied.

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
  "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx


[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux