Confusing rewrite rule: Need help!
I need a rewrite rule that will do an internal redirect from:
<domain>/directory/<anything>/<anything>.php
to:
<domain>/directory/<anything>.php
with <anything>
passed as a parameter, and it needs to leave all other parameters alone.
I get headaches from mod_rewrite. My issue is <anything>.php
, I cannot find any examples for anything like that.
Example: domain.com/directory/something/lol.php?param=value ought to 开发者_如何学Pythoninternally redirect to domain.com/directory/lol.php?param=value&someotherparam=something
Thanks for the help! I have read through many tutorial sites, but I am in the dark here...
EDIT: Code tags added since it wasnt showing up properly >.>
Not all pages will have other parameters passed, some might have only one, some might have many. This is another bit that confuses me...
RewriteEngine On
RewriteBase /
RewriteRule ^directory/([^/]+)/([^/]+)\.php$ directory/$2.php?someotherparam=$1 [QSA,L]
This will redirect domain.com/directory/something/lol.php?param=value
to domain.com/directory/lol.php?param=value&someotherparam=something
, as requested. (I'll note that currently, none of the other replies do so.)
RewriteEngine On
RewriteBase /
RewriteRule ^rewrite/(.+)/lol.php$ rewrite/lol.php?someotherparam=$1 [QSA,R,L]
精彩评论