SEO URL - Complete Rewrite
10 posts
• Page 1 of 1
- voidinutah
- Posts: 20
- Joined: 25 Sep 2014, 13:59
SEO URL - Complete Rewrite
I've been testing the mod_seo with the examples from the site and this is the functionality we are looking for. One item my client would like to do is instead of replacing part of the URL, they would like to completely rewrite it with one from our database. Let me give an example:
Original
http://www.mydomain.com/index.aspx?even ... ty&cID=549
SEO Version
http://www.mydomain.com/Cardiology/MD
We would retrieve from the database "Cardiology/MD" based on search for "index.aspx?event=activity&cID=549"
Can this be accomplished using mod_seo? And if so, how would the SeoRule and RewriteRule look? I'm already able to connect to the database and have RewriteMap in place, which was based on our testing for getting event title and rewriting the URL to include the title and remove the index.aspx and event. And I suspect I will need another call to the database for the RewriteRule.
And help would be greatly appreciated.
Original
http://www.mydomain.com/index.aspx?even ... ty&cID=549
SEO Version
http://www.mydomain.com/Cardiology/MD
We would retrieve from the database "Cardiology/MD" based on search for "index.aspx?event=activity&cID=549"
Can this be accomplished using mod_seo? And if so, how would the SeoRule and RewriteRule look? I'm already able to connect to the database and have RewriteMap in place, which was based on our testing for getting event title and rewriting the URL to include the title and remove the index.aspx and event. And I suspect I will need another call to the database for the RewriteRule.
And help would be greatly appreciated.
Re: SEO URL - Complete Rewrite
Hello,
Sure, what you describe can be accomplished with mod_seo.
To change the URL you need to use the rule like this:
SeoRule (index.aspx\?event=\w+&cID=\d+)$ ${slug:${SeoTopic:$1}} [Redirect, Scope=A]
and to rewrite it back you will need another mapfile with columns in reverse order and the rule like this:
RewriteCond ${mapfile:$1|NOT_FOUND} !NOT_FOUND
RewriteRule ^(.+)$ /${mapfile:$1} [NC,L]
Sure, what you describe can be accomplished with mod_seo.
To change the URL you need to use the rule like this:
SeoRule (index.aspx\?event=\w+&cID=\d+)$ ${slug:${SeoTopic:$1}} [Redirect, Scope=A]
and to rewrite it back you will need another mapfile with columns in reverse order and the rule like this:
RewriteCond ${mapfile:$1|NOT_FOUND} !NOT_FOUND
RewriteRule ^(.+)$ /${mapfile:$1} [NC,L]
- voidinutah
- Posts: 20
- Joined: 25 Sep 2014, 13:59
Re: SEO URL - Complete Rewrite
Thanks Anton!
What would the regEx be for the non SEO URL if I wanted any query string after the index.aspx? We have others that have more attributes then event and cID.
What would the regEx be for the non SEO URL if I wanted any query string after the index.aspx? We have others that have more attributes then event and cID.
Re: SEO URL - Complete Rewrite
"What would the regEx be for the non SEO URL if I wanted any query string after the index.aspx?"
- It should be like this:
SeoRule (index.aspx\?.+)$ ${slug:${SeoTopic:$1}} [Redirect, Scope=A]
- It should be like this:
SeoRule (index.aspx\?.+)$ ${slug:${SeoTopic:$1}} [Redirect, Scope=A]
- voidinutah
- Posts: 20
- Joined: 25 Sep 2014, 13:59
Re: SEO URL - Complete Rewrite
Thanks Anton! I'm getting close to having this working.
We ran into an issue while testing the format we want to use and I'm not sure if there a way to get the desired rendering results.
Our app runs everything through a common index.aspx page with events. Our images and scripts and other links are coded for the root of the app and not the web site (allowing use to move the app to the root of a site or subdirectory, if we wanted). So an image tag might be "src='image/...'" or scripts "src='scripts/...'" and links were simply "index.aspx?...".
Thus when we render the page for the seo format of "Cardiology/MD/page-title.html", the images, scripts, etc. are broken. Which makes sense.
Do I need to go in and re-code all these links, or is there a way to have the mod_seo handle this when rendering the page? I remember, with Link Freeze, there was a way to do this. I might be recalling incorrectly, because it has been years since we used Link Freeze. I don't remember having to recode links when we used that product.
Any direction on this will be helpful. Thank you!
We ran into an issue while testing the format we want to use and I'm not sure if there a way to get the desired rendering results.
Our app runs everything through a common index.aspx page with events. Our images and scripts and other links are coded for the root of the app and not the web site (allowing use to move the app to the root of a site or subdirectory, if we wanted). So an image tag might be "src='image/...'" or scripts "src='scripts/...'" and links were simply "index.aspx?...".
Thus when we render the page for the seo format of "Cardiology/MD/page-title.html", the images, scripts, etc. are broken. Which makes sense.
Do I need to go in and re-code all these links, or is there a way to have the mod_seo handle this when rendering the page? I remember, with Link Freeze, there was a way to do this. I might be recalling incorrectly, because it has been years since we used Link Freeze. I don't remember having to recode links when we used that product.
Any direction on this will be helpful. Thank you!
Re: SEO URL - Complete Rewrite
Hello,
One possible solution is to use 'base' tag in html to explicitly specify the base for URLs, e.g.:
<head>
<base href="http://www.w3schools.com/images/" target="_blank">
</head>
However, this may take quite a lot of efforts to put it in all necessary files.
Another option is to use splitter other than '/' for SEO-friendly URLs. E.g. '~': "Cardiology~MD~page-title.html"
Then the paths will not get corrupted.
One possible solution is to use 'base' tag in html to explicitly specify the base for URLs, e.g.:
<head>
<base href="http://www.w3schools.com/images/" target="_blank">
</head>
However, this may take quite a lot of efforts to put it in all necessary files.
Another option is to use splitter other than '/' for SEO-friendly URLs. E.g. '~': "Cardiology~MD~page-title.html"
Then the paths will not get corrupted.
- voidinutah
- Posts: 20
- Joined: 25 Sep 2014, 13:59
Re: SEO URL - Complete Rewrite
Thanks Anton! The base tag did the job nicely. Luckily my site was template based, so I only had to update about 5 files to affect the entire site.
- voidinutah
- Posts: 20
- Joined: 25 Sep 2014, 13:59
Re: SEO URL - Complete Rewrite
I must be missing something with my configuration. If the page I'm viewing is not converted by the SEO mod, then any links on that page that happen to have SEO links are converted. Thus when you hover over them, you see the friendly URLs. But as soon as I click on one of those links, those same links are no longer friendly URLs. The page itself is displaying the friend URL in the browser location. But for the navigation, the links that showed the friendly URL no longer does. Here is my configuration:
# Helicon Ape version 3.1.0.138
#put these rules into the /forum/.htaccess file
# Enable mod_rewrite and mod_seo for current location
RewriteEngine On
SetEnv mod_seo
# Connect to database
DBDriver mssql
DBDParams "connection string params"
# Prepare SQL queries to find topic or forum name by ID
DBDPrepareSQL "SELECT seo_url FROM seo_url_rewrite WHERE original_url =@KEY" getSeoURL
DBDPrepareSQL "SELECT original_url FROM seo_url_rewrite WHERE seo_url =@KEY" getOriginalURL
# Declare database rewrite maps
RewriteMap SeoURL dbd:getSeoURL
RewriteMap OriginalURL dbd:getOriginalURL
SeoCond ${SeoURL:$1|NOT_FOUND} !NOT_FOUND
SeoRule (index.aspx\?.+)$ ${SeoURL:$1} [Redirect, Scope=A]
RewriteCond ${OriginalURL:$1|NOT_FOUND} !NOT_FOUND
RewriteRule ^(.+)$ /${OriginalURL:$1} [NC,L]
# Helicon Ape version 3.1.0.138
#put these rules into the /forum/.htaccess file
# Enable mod_rewrite and mod_seo for current location
RewriteEngine On
SetEnv mod_seo
# Connect to database
DBDriver mssql
DBDParams "connection string params"
# Prepare SQL queries to find topic or forum name by ID
DBDPrepareSQL "SELECT seo_url FROM seo_url_rewrite WHERE original_url =@KEY" getSeoURL
DBDPrepareSQL "SELECT original_url FROM seo_url_rewrite WHERE seo_url =@KEY" getOriginalURL
# Declare database rewrite maps
RewriteMap SeoURL dbd:getSeoURL
RewriteMap OriginalURL dbd:getOriginalURL
SeoCond ${SeoURL:$1|NOT_FOUND} !NOT_FOUND
SeoRule (index.aspx\?.+)$ ${SeoURL:$1} [Redirect, Scope=A]
RewriteCond ${OriginalURL:$1|NOT_FOUND} !NOT_FOUND
RewriteRule ^(.+)$ /${OriginalURL:$1} [NC,L]
- voidinutah
- Posts: 20
- Joined: 25 Sep 2014, 13:59
Re: SEO URL - Complete Rewrite
One additional question, I have search results with pagination. Each link contains the criteria and the page number. I have gotten this to work for my SEO rule:
SeoRule (index\.aspx\?event=courses\.main)\&?(.*)? ${Seo_cme_browse_URL:$1}\?$2 [Redirect, Scope=A]
My question is what would the rewrite rule need to be for this? The SEO URLs are in a database, so would I expand upon my current rewrite rule
RewriteRule ^(.+)$ /${testOriginalURL:$1} [NC,L]
to get query string attributes, then append to my original URL. If so, what would the rule be then? Should I add any conditions?
Original: /index.aspx?event=courses.main&filter=0&specialtyID=0&creditType=0&sort=0&page=4
SEO: /cme-browse-test?filter=0&specialtyID=0&creditType=0&sort=0&page=4
Any help on this and the previous post would be greatly appreciated.
Thanks!
SeoRule (index\.aspx\?event=courses\.main)\&?(.*)? ${Seo_cme_browse_URL:$1}\?$2 [Redirect, Scope=A]
My question is what would the rewrite rule need to be for this? The SEO URLs are in a database, so would I expand upon my current rewrite rule
RewriteRule ^(.+)$ /${testOriginalURL:$1} [NC,L]
to get query string attributes, then append to my original URL. If so, what would the rule be then? Should I add any conditions?
Original: /index.aspx?event=courses.main&filter=0&specialtyID=0&creditType=0&sort=0&page=4
SEO: /cme-browse-test?filter=0&specialtyID=0&creditType=0&sort=0&page=4
Any help on this and the previous post would be greatly appreciated.
Thanks!
- voidinutah
- Posts: 20
- Joined: 25 Sep 2014, 13:59
Re: SEO URL - Complete Rewrite
I know this is probably not clean and someone with more experience will format this better, but here is what I came up with to handle pagination, in case anyone else needs to do it. Still don't know why the links on the SEO pages show the old URL style when the non-SEO pages show SEO links. Maybe its the fact they are rewritten so the SEO process cannot happen. The links still work and go to the SEO URL, so I can live with that. Just would be nice to have the links show the SEO URL when rolling over.
# Helicon Ape version 3.1.0.138
#put these rules into the /forum/.htaccess file
# Enable mod_rewrite and mod_seo for current location
RewriteEngine On
SetEnv mod_seo
# Connect to database
DBDriver mssql
DBDParams "connection string params"
# Prepare SQL queries to find topic or forum name by ID
DBDPrepareSQL "SELECT seo_url FROM seo_url_rewrite WHERE original_url =@KEY" getSeoURL
DBDPrepareSQL "SELECT original_url as Subject FROM seo_url_rewrite WHERE seo_url =@KEY" getOriginalURL
# Declare database rewrite maps
RewriteMap SeoURL dbd:getSeoURL
RewriteMap OriginalURL dbd:getOriginalURL
SeoCond %{QUERY_STRING} ^([^&]*&)*page=([^&]+)
SeoCond ${SeoURL:$1|NOT_FOUND} !NOT_FOUND
SeoRule (index\.aspx\?event=courses\.main)\&?(.*)? ${SeoURL:$1}\?$2 [Redirect, Scope=A]
SeoCond ${SeoURL:$1|NOT_FOUND} !NOT_FOUND
SeoRule (index.aspx\?.+)$ ${SeoURL:$1} [Redirect, Scope=A]
RewriteCond %{QUERY_STRING} ^([^&]*&)*page=([^&]+)
RewriteCond ${OriginalURL:$1|NOT_FOUND} !NOT_FOUND
RewriteRule ^((.+).html)$ ${OriginalURL:$1} [NC,L, QSA]
RewriteCond ${OriginalURL:$1|NOT_FOUND} !NOT_FOUND
RewriteRule ^(.+)$ /${OriginalURL:$1} [NC,L]
# Helicon Ape version 3.1.0.138
#put these rules into the /forum/.htaccess file
# Enable mod_rewrite and mod_seo for current location
RewriteEngine On
SetEnv mod_seo
# Connect to database
DBDriver mssql
DBDParams "connection string params"
# Prepare SQL queries to find topic or forum name by ID
DBDPrepareSQL "SELECT seo_url FROM seo_url_rewrite WHERE original_url =@KEY" getSeoURL
DBDPrepareSQL "SELECT original_url as Subject FROM seo_url_rewrite WHERE seo_url =@KEY" getOriginalURL
# Declare database rewrite maps
RewriteMap SeoURL dbd:getSeoURL
RewriteMap OriginalURL dbd:getOriginalURL
SeoCond %{QUERY_STRING} ^([^&]*&)*page=([^&]+)
SeoCond ${SeoURL:$1|NOT_FOUND} !NOT_FOUND
SeoRule (index\.aspx\?event=courses\.main)\&?(.*)? ${SeoURL:$1}\?$2 [Redirect, Scope=A]
SeoCond ${SeoURL:$1|NOT_FOUND} !NOT_FOUND
SeoRule (index.aspx\?.+)$ ${SeoURL:$1} [Redirect, Scope=A]
RewriteCond %{QUERY_STRING} ^([^&]*&)*page=([^&]+)
RewriteCond ${OriginalURL:$1|NOT_FOUND} !NOT_FOUND
RewriteRule ^((.+).html)$ ${OriginalURL:$1} [NC,L, QSA]
RewriteCond ${OriginalURL:$1|NOT_FOUND} !NOT_FOUND
RewriteRule ^(.+)$ /${OriginalURL:$1} [NC,L]
10 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest