Problems with RewriteMap
7 posts
• Page 1 of 1
Problems with RewriteMap
Have researched and tested several examples in the forum, but so far not been successful.
My Current URL
http://www.mysite.com.br/guiadacidade/index.asp?Cod=1
I need her to be well
http://www.mysite.com.br/guiadacidade/paone_product
First attempt - My. Htaccess is
2 - try, is not writing the log and I've given permission to the folder.
my mapfile.txt
error message on the site
The system can not find the file specified.
It would be very grateful for those who give me a light
My Current URL
http://www.mysite.com.br/guiadacidade/index.asp?Cod=1
I need her to be well
http://www.mysite.com.br/guiadacidade/paone_product
First attempt - My. Htaccess is
- Code: Select all
RewriteEngine on
RewriteMap mapfile txt:mapfile.txt
RewriteMap lower int:tolower
RewriteCond %{REQUEST_URI} ^/([^/]+)/([^/.]+)/$ [NC]
RewriteCond ${mapfile:${lower:%2}|NOT_FOUND} !NOT_FOUND
RewriteRule .? /guiadacidade/index.asp?cod=${mapfile:${lower:%2}} [NC,L]
2 - try, is not writing the log and I've given permission to the folder.
- Code: Select all
RewriteEngine on
LogLevel debug
RewriteLog e:/vhosts/mysite.com.br/httpdocs/test/rewrite.log
RewriteLogLevel 9
RewriteRule ^/via/?([a-zA-Z0-9_-]+)?(.html)?$ /via-de-contas-bm.asp[I,L]
RewriteBase /
RewriteMap mapfile txt:mapfile.txt
RewriteRule ^guiadacidade/([^?/]+)\.asp /index.asp?Cod=${mapfile:$1}
my mapfile.txt
- Code: Select all
paone_product 1
another_product 2
our_super_tool 127
more_products 335
error message on the site
The system can not find the file specified.
It would be very grateful for those who give me a light
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: Problems with RewriteMap
Hello,
I assume you need both... redirect from guiadacidade/index.asp?Cod=1 --> to --> guiadacidade/paone_product and at the same time also to load content from guiadacidade/index.asp?Cod=1 for this new page. Correct?
There's the following set of rules:
Where mapfile looks like:
and revmapfile.txt looks like:
Both are supposed to be located by the config file with the rules(in the same directory)
Regards
Andrew
I assume you need both... redirect from guiadacidade/index.asp?Cod=1 --> to --> guiadacidade/paone_product and at the same time also to load content from guiadacidade/index.asp?Cod=1 for this new page. Correct?
There's the following set of rules:
- Code: Select all
RewriteEngine on
RewriteMap mapfile txt:mapfile.txt
RewriteMap revmapfile txt:revmapfile.txt
# 301-REDIRECT from old URL to a new one
RewriteCond %{QUERY_STRING} ^Cod=(\d+)$ [NC]
RewriteRule ^guiadacidade/index\.asp$ /guiadacidade/${mapfile:%1} [NC,R=301,L]
# rewrite to load content
RewriteCond ${revmapfile:$1|NOT_FOUND} !NOT_FOUND
RewriteRule ^guiadacidade/([^/]+)$ /guiadacidade/index.asp?Cod=${revmapfile:$1} [NC,L]
Where mapfile looks like:
- Code: Select all
1 paone_product
2 another_product
127 our_super_tool
335 more_products
and revmapfile.txt looks like:
- Code: Select all
paone_product 1
another_product 2
our_super_tool 127
more_products 335
Both are supposed to be located by the config file with the rules(in the same directory)
Regards
Andrew
Re: Problems with RewriteMap
Hello
With the code you posted, my url looks like this
http://www.mysite.com.br/guiadacidade/?Cod=1
I need it looks like this
http://www.mysite.com.br/guiadacidade/paone_product
can you help me solve?
With the code you posted, my url looks like this
http://www.mysite.com.br/guiadacidade/?Cod=1
I need it looks like this
http://www.mysite.com.br/guiadacidade/paone_product
can you help me solve?
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: Problems with RewriteMap
the only thing I'd fix is the following:
replace
with
In case it doesn't change anything - check your mapfile.
You may also provide rewrite.log for the testing request. Logging issues described in FAQ
Regards
Andrew
replace
- Code: Select all
# 301-REDIRECT from old URL to a new one
RewriteCond %{QUERY_STRING} ^Cod=(\d+)$ [NC]
RewriteRule ^guiadacidade/index\.asp$ /guiadacidade/${mapfile:%1} [NC,R=301,L]
with
- Code: Select all
# 301-REDIRECT from old URL to a new one
RewriteCond %{QUERY_STRING} ^Cod=(\d+)$ [NC]
RewriteRule ^guiadacidade/index\.asp$ /guiadacidade/${mapfile:%1}? [NC,R=301,L]
In case it doesn't change anything - check your mapfile.
You may also provide rewrite.log for the testing request. Logging issues described in FAQ
Regards
Andrew
Re: Problems with RewriteMap
This almost working, getting this way:
original
http://www.mysite.com.br/guiadacidade/index.asp?Cod=1
it thereby
http://www.mysite.com.br/guiadacidade/p ... duct?Cod=1
I need to stay well
http://www.mysite.com.br/guiadacidade/paone_product
original
http://www.mysite.com.br/guiadacidade/index.asp?Cod=1
it thereby
http://www.mysite.com.br/guiadacidade/p ... duct?Cod=1
I need to stay well
http://www.mysite.com.br/guiadacidade/paone_product
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: Problems with RewriteMap
You probably haven't noticed the changes in my last post: it's '?' at the end of the redirect rule, it prevents from appending the querystring to your final URL.
Regards
Andrew
Regards
Andrew
Re: Problems with RewriteMap
Thank you Andrew
It worked perfectly.
But now another question came to me, sometimes I have several pages.
As an example below
My Current URL
http://www.mysite.com.br/guiadacidade/i ... 1&Pagina=2
I need her to be well
http://www.mysite.com.br/guiadacidade/paone_product/2
it is possible to adapt your previous solution?
and again thank you
It worked perfectly.
But now another question came to me, sometimes I have several pages.
As an example below
My Current URL
http://www.mysite.com.br/guiadacidade/i ... 1&Pagina=2
I need her to be well
http://www.mysite.com.br/guiadacidade/paone_product/2
it is possible to adapt your previous solution?
and again thank you
7 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 0 guests