themistral Posted February 2, 2008 Share Posted February 2, 2008 Hi all - still trying to get to grips with modrewrite! I have managed to get my querystrings to write to a usable url. However, I have to parse some of my querystring variables with underscores. I have tried using hyphens instead of underscores in my querystring variables but it then messes up and returns the wrong values when using $_GET. Is there a way I can perform another rewrite on the rule I have already made to change the underscores to hyphens and still have the $_GET command use the correct variables? My existing rule RewriteRule ^(.+)-(.+)-by-(.+)\.html$ shows.php?showid=$1&showname=$2&writer=$3 which will produce a URL such as www.mydoman.com/1-show_name-by-a_writer.html I have looked at a lot of tutorials but I just can't seem to get my head around this! Quote Link to comment Share on other sites More sharing options...
madmax Posted February 2, 2008 Share Posted February 2, 2008 Interesting problem. Not really suited to mod_rewrite and it will only remap the URL reference at the server end (the user will see no difference unless you redirect) This was the closest I could research with ingenious use of mod_rewrite http://www.webmasterworld.com/apache/3503715.htm This Google search may be useful http://www.google.com/search?q=mod+rewrite+character+replace Quote Link to comment Share on other sites More sharing options...
themistral Posted February 2, 2008 Author Share Posted February 2, 2008 Fair enough - I wasn't sure if it was something that could be done. I was hoping to avoid it, but I should be able (hopefully) to sort it out using string manipulation in my PHP script - going to take some thinking about!! Thanks for the reply madmax! I will look over your suggestions and see if any are of help! Quote Link to comment Share on other sites More sharing options...
madmax Posted February 2, 2008 Share Posted February 2, 2008 For the benefit of anyone else stumbling over this thread - This would be really best done in an add-on module. I was looking over the C source code for mod_apachecon which translates spaces to %20 codes - it would be straightforward to rewrite this to do the job. However it lacks conditional configuration and I'm not familiar enough with the Apache API to know how to import configuration directives without breaking something! The only other alternative would be a hard-coded module. This question seems to come up a lot so I'm surprised that someone hasn't knocked-up a module to do the job with proper filtering and location context configs. http://www.google.com/search?q=mod_apachecon Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.