Welcome to WebmasterWorld Guest from

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

mod rewrite a php file to a xml

11:33 am on Jun 19, 2013 (gmt 0)

New User

joined:June 19, 2013
votes: 0

Hello Forum,

I am trying to to rewrite /mail/config-v1.1.xml to autoconfig.php and saving possible parameters like "?emailaddress=name@doma.in", so that "http://domain.de/mail/config-v1.1.xml?emailaddress=name@doma.in" leads to "autoconfig.php?emailaddress=name@doma.in"

But the parameters should be optional; that is what I am trying in the first rule.

RewriteEngine on
RewriteRule ^/mail/config-v1\.1\.xml(\?)?(.*)$ /autoconfig.php [L]
RewriteRule ^/mail/config-v1\.1\.xml\?emailaddress=(.*)$ /autoconfig.php?($1) [L]
12:01 pm on June 19, 2013 (gmt 0)


WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Aug 10, 2004
votes: 8

welcome to WebmasterWorld, debianer!

you cannot examine the query string in the RewriteRule Pattern - you have to use a RewriteCond directive for that.
however in your case, you aren't testing or capturing anything in the query string, you are reusing all of it - intact.
by default, the query string is passed through unchanged.

also, depending on the context in which your RewriteRule is implemented, the path information of the request can be modified by the server's mod_rewrite processing.
if your RewriteRule is in the .htaccess file of the document root diretory, then the leading slash will be stripped from the requested url.

assuming this, you probably are good with something like this:
RewriteEngine on
RewriteRule ^mail/config-v1\.1\.xml$ /autoconfig.php [L]
2:18 pm on June 19, 2013 (gmt 0)

New User

joined:June 19, 2013
votes: 0

Hi phranque,

thanks for your fast reply and the warm welcome. Your ruleset help me achieving my goal.