(seo|rewrite)rules and databases
6 posts
• Page 1 of 1
(seo|rewrite)rules and databases
Hi to all!
I want to rewrite urls with a backend database.
To do that, i've created a table called SEO_URL_REWRITE with 2 column named ORIGINAL_URL and SEO_URL.
My goal is to call SEO_URL record with ORIGINAL_URL key with SeoCond/SeoRule syntax, and do the reverse call ORIGINAL_URL record with SEO_URL key with RewriteCond/RewriteRule syntax, because i want to show same pages with different urls (for example, original page like www.mydomain.com/WHO_ARE_US.asp and URL like www.mydomain.com/who-are-us.html).
To do this, I've used an example you made in the mod_rewrite page, so i wrote:
RewriteEngine On
SetEnv mod_seo
RewriteBase /
DBDriver mssql
DBDParams "*Correct parameters to connect db*"
DBDPrepareSQL "select SEO_URL from SEO_URL_REWRITE where Original_URL=@KEY" getSEO
DBDPrepareSQL "select Original_URL from SEO_URL_REWRITE where SEO_URL=@KEY" getOriginal
RewriteMap dest01 dbd:getSEO
RewriteMap dest02 dbd:getOriginal
SeoCond ${dest01:$1|NOT_FOUND} (.*)
SeoCond %1 !NOT_FOUND
SeoRule (.+) %1 [Redirect, Scope=ALL]
RewriteCond ${dest02:$1|NOT_FOUND} (.*)
RewriteCond %1 !NOT_FOUND
RewriteRule (.+) %1 [L]
The seoCond/seoRule instructions work correctly, but not the RewriteCond/RewriteRule instructions, in fact the server returns 404 page. There's a syntax or run-time error? Thanks a lot for your help!
I want to rewrite urls with a backend database.
To do that, i've created a table called SEO_URL_REWRITE with 2 column named ORIGINAL_URL and SEO_URL.
My goal is to call SEO_URL record with ORIGINAL_URL key with SeoCond/SeoRule syntax, and do the reverse call ORIGINAL_URL record with SEO_URL key with RewriteCond/RewriteRule syntax, because i want to show same pages with different urls (for example, original page like www.mydomain.com/WHO_ARE_US.asp and URL like www.mydomain.com/who-are-us.html).
To do this, I've used an example you made in the mod_rewrite page, so i wrote:
RewriteEngine On
SetEnv mod_seo
RewriteBase /
DBDriver mssql
DBDParams "*Correct parameters to connect db*"
DBDPrepareSQL "select SEO_URL from SEO_URL_REWRITE where Original_URL=@KEY" getSEO
DBDPrepareSQL "select Original_URL from SEO_URL_REWRITE where SEO_URL=@KEY" getOriginal
RewriteMap dest01 dbd:getSEO
RewriteMap dest02 dbd:getOriginal
SeoCond ${dest01:$1|NOT_FOUND} (.*)
SeoCond %1 !NOT_FOUND
SeoRule (.+) %1 [Redirect, Scope=ALL]
RewriteCond ${dest02:$1|NOT_FOUND} (.*)
RewriteCond %1 !NOT_FOUND
RewriteRule (.+) %1 [L]
The seoCond/seoRule instructions work correctly, but not the RewriteCond/RewriteRule instructions, in fact the server returns 404 page. There's a syntax or run-time error? Thanks a lot for your help!
Re: (seo|rewrite)rules and databases
Hello,
There are no obvious mistakes I can see, so it would be helpful to see rewrite.log records which you will gt in Ape install folder after you put
RewriteLogLevel 9
in httpd.conf file.
Also, please show several lines from both of your mapfiles to make sure they are correct.
There are no obvious mistakes I can see, so it would be helpful to see rewrite.log records which you will gt in Ape install folder after you put
RewriteLogLevel 9
in httpd.conf file.
Also, please show several lines from both of your mapfiles to make sure they are correct.
Re: (seo|rewrite)rules and databases
Here it is rewrite.log file.
The mapfiles dest01 and dest02 are strangely empty...
in mapfile.txt there are written:
http://mydomain.it/ITA/Home.asp http://mydomain.it/ITA/Home.html
in revmapfile.txt there are written:
http://mydomain.it/ITA/Home.html http://mydomain.it/ITA/Home.asp
The mapfiles dest01 and dest02 are strangely empty...
in mapfile.txt there are written:
http://mydomain.it/ITA/Home.asp http://mydomain.it/ITA/Home.html
in revmapfile.txt there are written:
http://mydomain.it/ITA/Home.html http://mydomain.it/ITA/Home.asp
- Attachments
-
- rewrite.log
- (5.39 KiB) Downloaded 1541 times
Re: (seo|rewrite)rules and databases
Hello,
How can it be that "The seoCond/seoRule instructions work correctly" if the mapfiles are empty?
Can you also try to simplify your rules like this:
SeoCond ${dest01:$1|NOT_FOUND} !NOT_FOUND
SeoRule (.+) ${dest01:$1} [Redirect, Scope=ALL]
RewriteCond ${dest02:$1|NOT_FOUND} !NOT_FOUND
RewriteRule (.+) ${dest02:$1} [L]
How can it be that "The seoCond/seoRule instructions work correctly" if the mapfiles are empty?
Can you also try to simplify your rules like this:
SeoCond ${dest01:$1|NOT_FOUND} !NOT_FOUND
SeoRule (.+) ${dest01:$1} [Redirect, Scope=ALL]
RewriteCond ${dest02:$1|NOT_FOUND} !NOT_FOUND
RewriteRule (.+) ${dest02:$1} [L]
Re: (seo|rewrite)rules and databases
I've tried to insert these 2 strings:
http://mydomain.it/ITA/Home.asp http://mydomain.it/ITA/Home.html in dest01
http://mydomain.it/ITA/Home.html http://mydomain.it/ITA/Home.asp in dest02
but nothing changed.
I don't know why seo(cond|rule) part works correctly with dest01 and dest02 empty, I usually work with seo/rewrite rules and databases using specified rules for any page, but I want to write one rule for all my sites. For example I have a site with 33 mapfiles (named dest01, dest02 and so on) and it works correctly without any destXX file in the path. It's very strange!
Unfortunately the suggest you wrote (seo/rewrite) part doesn't work (same 404 error). Any other ideas? Thank you very much!
http://mydomain.it/ITA/Home.asp http://mydomain.it/ITA/Home.html in dest01
http://mydomain.it/ITA/Home.html http://mydomain.it/ITA/Home.asp in dest02
but nothing changed.
I don't know why seo(cond|rule) part works correctly with dest01 and dest02 empty, I usually work with seo/rewrite rules and databases using specified rules for any page, but I want to write one rule for all my sites. For example I have a site with 33 mapfiles (named dest01, dest02 and so on) and it works correctly without any destXX file in the path. It's very strange!
Unfortunately the suggest you wrote (seo/rewrite) part doesn't work (same 404 error). Any other ideas? Thank you very much!
Re: (seo|rewrite)rules and databases
Solved!
I've wrote
SeoCond ${dest01:$1|NOT_FOUND} !NOT_FOUND
SeoRule (.+) /${dest01:$1} [Redirect]
RewriteCond ${dest02:$1|NOT_FOUND} !NOT_FOUND
RewriteRule (.+) ${dest02:$1}
In db, SEO_URL record don't want to have first /, for example
ITA/Home.html instead of /ITA/Home.html
because (in my opinion) Substitution part of rules must have at least one fixed character.
I've wrote
SeoCond ${dest01:$1|NOT_FOUND} !NOT_FOUND
SeoRule (.+) /${dest01:$1} [Redirect]
RewriteCond ${dest02:$1|NOT_FOUND} !NOT_FOUND
RewriteRule (.+) ${dest02:$1}
In db, SEO_URL record don't want to have first /, for example
ITA/Home.html instead of /ITA/Home.html
because (in my opinion) Substitution part of rules must have at least one fixed character.
6 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 30 guests