Rewrite Query - removing characters
4 posts
• Page 1 of 1
Rewrite Query - removing characters
Hi,
I'm using a client's server, with Isapi_Rewrite 2.8 installed and have the following query. I am a complete novice on Rewrite, so apologies for asking possibly daft questions - just trying to get my head around what I can achieve with it!
Is it possible to take an url such as:
http://www.my-site.com/result.php?Product/Iron Filings&b=384005
and create a rule to do these three things:
1. remove 'result.php?'
2. replace spaces with a hyphen
3. hide '&b=' and anything after it
to display as:
http://www.my-site.com/Product/Iron-Filings
Thanks for your help!
I'm using a client's server, with Isapi_Rewrite 2.8 installed and have the following query. I am a complete novice on Rewrite, so apologies for asking possibly daft questions - just trying to get my head around what I can achieve with it!
Is it possible to take an url such as:
http://www.my-site.com/result.php?Product/Iron Filings&b=384005
and create a rule to do these three things:
1. remove 'result.php?'
2. replace spaces with a hyphen
3. hide '&b=' and anything after it
to display as:
http://www.my-site.com/Product/Iron-Filings
Thanks for your help!
Re: Rewrite Query - removing characters
Hello,
What you say is partially possible, but I'm afraid removing "&b=384005" is not.
What we can try to do this:
http://www.my-site.com/result.php?Product/Iron Filings&b=384005
to
http://www.my-site.com/Product/Iron-Filings/384005
Please try the following config:
[ISAPI_Rewrite]
RewriteRule /result\.php\?Product/([^&]+)&b=(\d+) /Product/$1/$2
RewriteRule (\S)(?:\%20|\s)(\S) $1-$2 [I,NS,RP]
RewriteRule (/Product/([^-]+)-(.+) $1\ $2 [I,NS]
RewriteRule /Product/([^/.]+)/(\d+) /result.php?Product/$1&b=$2 [I,L]
What you say is partially possible, but I'm afraid removing "&b=384005" is not.
What we can try to do this:
http://www.my-site.com/result.php?Product/Iron Filings&b=384005
to
http://www.my-site.com/Product/Iron-Filings/384005
Please try the following config:
[ISAPI_Rewrite]
RewriteRule /result\.php\?Product/([^&]+)&b=(\d+) /Product/$1/$2
RewriteRule (\S)(?:\%20|\s)(\S) $1-$2 [I,NS,RP]
RewriteRule (/Product/([^-]+)-(.+) $1\ $2 [I,NS]
RewriteRule /Product/([^/.]+)/(\d+) /result.php?Product/$1&b=$2 [I,L]
Re: Rewrite Query - removing characters
Thank you very much Anton! Works like a charm, and also it's a great help to use it as a working example for further rewrites (I've already had a fiddle and make some other bits work off the back of this).
I am getting some broken images on the resulting page, however I noted that in some other posts here, so I'm sure I'll sort it out.
Thanks again!
I am getting some broken images on the resulting page, however I noted that in some other posts here, so I'm sure I'll sort it out.
Thanks again!
Re: Rewrite Query - removing characters
This could work as other characters seem like distorted or something, but anyway, you might want to share whenever you been able to sort it out.
4 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 5 guests