On 01.03.2006 21:06 Uhr, Mark Wheeler <email@hidden> wrote:
> # Set the RewriteBase to "/" for the root level to base everything
> on... I guess.
> RewriteBase /
>
> RewriteRule ^oldpage.php(.+) newpage.php$1&otherid=0 [R]
> -------------------------------------------------
>
> The $1 should have all the variable stuff in it from the php.
>
> So I'm looking for it to essentially do this:
>
> oldpage.php?id=1 redirects to newpage.php?id=1&otherid=0
>
> Why is this not working? Any help would be appreciated.
Hey,
mod_rewrite is the swiss army knife of web deployment, so how could this be
OT? ;-)
Firstly, you're missing a question mark in your rewrite rule, every request
will at least start with a SLASH (/) and then adding QSA to your rewrite
rule might help in passing over query strings.
(QSA = QeryStringAppend)
^ matches the begining of the requested URI which will always start with a
slash as in:
http//www.apple.com/hardware
^ protocol
^ host
^ requested URI including /
So give this a try:
RewriteRule ^/oldpage.php(.*) newpage.php?$1&otherid=0 [QSA,R]
^ ^ ^^^
this is needed you missed this this QSA is new
or even
RewriteRule ^/oldpage.php(.*) newpage.php?$1&otherid=0 [QSA,R=301]
(R=301 makes the redirect a PERMANENT redirect)
I'd even go so far to add a Rewrite Condition, so the rule doesn't have to
be run for all requests:
RewriteCond %{REQUEST_URI} ^/.*\.php.* [NC]
RewriteRule ^oldpage.php(.*) newpage.php?$1&otherid=0 [QSA,R=301]
([NC] turns on case insensitivenes on the matches so .PHP=.php etc.)
Also to debug problems with ModRewrite, it realy helps turning logging on to
see what is actualy happening:
RewriteLog "/var/log/httpd/rewrite.log"
RewriteLogLevel 13
(just comment the logging out when you're done testing)
--
Stefan Seiz <http://www.stefanseiz.com>
Spamto: <email@hidden>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Web-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/web-dev/email@hidden
This email sent to email@hidden