rewrite url products id and macrocat
8 posts
• Page 1 of 1
- HeliconAndrew
-
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: rewrite url products id and macrocat
Hello,
You'll need mapfiles for that. See more here
Try using the following:
Tha mapfiles macro_mapfile.txt and pag_mapfile.txt are supposed to be located in the same folder as the rules. The content must look as following:
macro_mapfile.txt
pag_mapfile.txt
Regards
Andrew
You'll need mapfiles for that. See more here
Try using the following:
- Code: Select all
RewriteEngine on
RewriteBase /
RewriteMap macro_mapfile txt:macro_mapfile.txt
RewriteMap pag_mapfile txt:pag_mapfile.txt
RewriteCond %{QUERY_STRING} ^idmacrocat=([^&]+)$ [NC]
RewriteCond ${macro_mapfile:%1|NOT_FOUND} !NOT_FOUND
Rewriterule ^pagine\.asp$ /${macro_mapfile:%1}.asp [NC,R=301,L]
RewriteCond %{QUERY_STRING} ^idmacrocat=([^&]+)&idpag=([^&]+)$ [NC]
RewriteCond ${macro_mapfile:%1|NOT_FOUND} !NOT_FOUND
RewriteCond ${pag_mapfile:%2|NOT_FOUND} !NOT_FOUND
Rewriterule ^pagine_detail.asp$ /${macro_mapfile:%1}/${pag_mapfile:%2}.asp [NC,R=301,L]
Tha mapfiles macro_mapfile.txt and pag_mapfile.txt are supposed to be located in the same folder as the rules. The content must look as following:
macro_mapfile.txt
- Code: Select all
1 nameofmacrocat
454 nameofmacrocat234
34 nameofmacrocat4545
pag_mapfile.txt
- Code: Select all
33 nameofpag
23 nameofpag1
11 nameofpag7
Regards
Andrew
Re: rewrite url products id and macrocat
sorry same problem in other post
I think I misinterpreted the speech of url rewriting
the rule would be contrary to
from
http://www.mydomain.com/nameofmacrocat.asp
to
http://www.mydomain.com/pagine.asp?idmacrocat=1
and
from
http://www.mydomain.com/nameofmacrocat/nameofpag.asp
in
http://www.mydomain.com/pagine_detail.a ... &idpag=333
![Embarrassed :oops:](./images/smilies/icon_redface.gif)
I think I misinterpreted the speech of url rewriting
the rule would be contrary to
from
http://www.mydomain.com/nameofmacrocat.asp
to
http://www.mydomain.com/pagine.asp?idmacrocat=1
and
from
http://www.mydomain.com/nameofmacrocat/nameofpag.asp
in
http://www.mydomain.com/pagine_detail.a ... &idpag=333
- HeliconAndrew
-
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: rewrite url products id and macrocat
Well, that' vice versa:
And your mapfiles are supposed to have their entries changed places.
Regards
Andrew
- Code: Select all
RewriteEngine on
RewriteBase /
RewriteMap rev_macro_mapfile txt:rev_macro_mapfile.txt
RewriteMap rev_pag_mapfile txt:rev_pag_mapfile.txt
RewriteCond ${rev_macro_mapfile:$1|NOT_FOUND} !NOT_FOUND
Rewriterule ^([^/]+)$ /pagine.asp?idmacrocat=${rev_macro_mapfile:$1} [NC,L]
RewriteCond ${rev_macro_mapfile:$1|NOT_FOUND} !NOT_FOUND
RewriteCond ${rev_pag_mapfile:$2|NOT_FOUND} !NOT_FOUND
Rewriterule ^([^/]+)/([^/]+)$ /pagine_detail.asp?idmacrocat=${rev_macro_mapfile:$1}&idpag=${rev_pag_mapfile:$2} [NC,L]
And your mapfiles are supposed to have their entries changed places.
Regards
Andrew
Re: rewrite url products id and macrocat
HeliconAndrew wrote:And your mapfiles are supposed to have their entries changed places.
mean so
macro_mapfile.txt
Code: Select all
nameofmacrocat 1
nameofmacrocat234 454
nameofmacrocat454 534
pag_mapfile.txt
Code: Select all
nameofpag 33
nameofpag1 23
nameofpag7 11
Re: rewrite url products id and macrocat
two questions
nameofpag must be the name of the page in its entirety with the extension
or it may be just the file name without extension?
what is the best way to manage the map file, since the data should I take them from the table of categories and products I have every time you change or add a new record recreate the file
should be one thing but in that split instant of time when a user is browsing the site can happen that there is some error due at that time the file is not updated / does not exist
nameofpag must be the name of the page in its entirety with the extension
or it may be just the file name without extension?
what is the best way to manage the map file, since the data should I take them from the table of categories and products I have every time you change or add a new record recreate the file
should be one thing but in that split instant of time when a user is browsing the site can happen that there is some error due at that time the file is not updated / does not exist
- HeliconAndrew
-
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: rewrite url products id and macrocat
Hello,
1) I've created the rule so that you show only the name of the file. It's more reliable by the means of regular expressions
2) Our customers use custom way of importing or exporting entries from mapfile, as it varies from the database and other parameters. So we can't suggest any particular way.
Regards
Andrew
1) I've created the rule so that you show only the name of the file. It's more reliable by the means of regular expressions
2) Our customers use custom way of importing or exporting entries from mapfile, as it varies from the database and other parameters. So we can't suggest any particular way.
Regards
Andrew
8 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 21 guests