RewriteRule matching filename not url in substitution

Problems with the Linux version of XAMPP, questions, comments, and anything related.

RewriteRule matching filename not url in substitution

Postby brainchild » 28. October 2012 17:24

I wrote a CGI script (in python) that transforms XML files into XHTML for display in the client.

It is invoked as follows: http://hostname/path/scriptname.py?p=filename.xml

However, I much prefer a cleaner URL to be seen by the client: http://hostname/path/filename

The solution seems to be a RewriteRule directive. Since I am using shared hosting, I do not have access to httpd.conf. However, I am able to create an .htaccess file in the /path directory.

Creating such a file in the /path directory, it would seem that the correct rule is:
RewriteRule ^(.+)$ index.py?p=$1.xml

Strangely, when this rule is executed for the above clean version of the path, $1 is actually set to "index.py", not "filename". This is useless, because I already know the name of the script. What I don't know is the final component of the request URL. How can I fix the rule to set $1 to "filename"?

Thanks.
brainchild
 
Posts: 1
Joined: 28. October 2012 12:31
Operating System: Linux

Return to XAMPP for Linux

Who is online

Users browsing this forum: No registered users and 23 guests