How Can I ReWrite flat link to a dynamic link and preserve the Query string?
Posted
by jeremysawesome
on Stack Overflow
See other posts from Stack Overflow
or by jeremysawesome
Published on 2010-04-28T00:16:02Z
Indexed on
2010/04/28
0:23 UTC
Read the original article
Hit count: 281
Hello All,
I am wanting to rewrite a url like:
http://my.project/mydomain.com/ANY_NUMBER_OF_CATEGORIES/designer/4/designer-name/page.html
to this:
http://my.projects/mydomain.com/ANY_NUMBER_OF_CATEGORIES/page.html?designer=4
I would like to use mod-rewrite to accomplish this.
Things to note:
- Any number of categories can be between 'mydomain.com/' and '/designer'.
- For instance the url could be http://my.project/mydomain.com/designer/4/designer-name/page.html or it could be http://my.project/mydomain.com/tops/shirts/small/designer/4/designer-name/page.html
- A query string may be provided in the original url that needs to be preserved in the rewritten url.
- For example url provided could be: http://my.project/mydomain.com/designer/4/designer-name/page.html?color=red&type=shirt
- Given the url above the resulting url would need to be: http://my.projects/mydomain.com/page.html?designer=4&color=red&type=shirt
- The order of the query string does not matter. The 'designer=4' part could come before or after the rest of the query string.
I'm new to .htaccess and re-writes so any examples and or explanations would be greatly appreciated. Thank you very much.
© Stack Overflow or respective owner