homepage Welcome to WebmasterWorld Guest from 54.197.147.90
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
mod rewrite a php file to a xml
debianer




msg:4585689
 11:33 am on Jun 19, 2013 (gmt 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]

 

phranque




msg:4585692
 12:01 pm on Jun 19, 2013 (gmt 0)

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]

debianer




msg:4585742
 2:18 pm on Jun 19, 2013 (gmt 0)

Hi phranque,

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved