Jump to content

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/89046-solved-help-with-underscores-to-hyphens/
Share on other sites

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

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!

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.