Rewrite image tag from http to https
10 posts
• Page 1 of 1
- voidinutah
- Posts: 20
- Joined: 25 Sep 2014, 13:59
Rewrite image tag from http to https
Hello,
I have a site that is moving to SSL for the entire site. I have the redirect rule in place for this. But we have some images that have the full domain name in the imgage tag. Is there a rewrite rule that will allow me to have these images display in https? I rather not have to change all these image tags. And if it would be easier to have it be for any tag having http://www.mydomain.com, then that would be better. Even though I haven't found any css or javascript using the full domain, we would be covered.
Thanks for you help,
Marc
I have a site that is moving to SSL for the entire site. I have the redirect rule in place for this. But we have some images that have the full domain name in the imgage tag. Is there a rewrite rule that will allow me to have these images display in https? I rather not have to change all these image tags. And if it would be easier to have it be for any tag having http://www.mydomain.com, then that would be better. Even though I haven't found any css or javascript using the full domain, we would be covered.
Thanks for you help,
Marc
Re: Rewrite image tag from http to https
Hello Marc,
I guess what you need is the mod_replace module of Ape: http://www.helicontech.com/ape/doc/mod_replace.htm
You can replace the http links on pags with https.
I guess what you need is the mod_replace module of Ape: http://www.helicontech.com/ape/doc/mod_replace.htm
You can replace the http links on pags with https.
- voidinutah
- Posts: 20
- Joined: 25 Sep 2014, 13:59
Re: Rewrite image tag from http to https
Thanks Anton, this put me on the right track. I got it to work with the string, but I would like to have it work with a regex for the maintain the hostname of the URL. I tried a couple of different regex but couldn't get it to work. Here is the example:
ReplaceFilterDefine http_to_https_filter CaseIgnore intype=text/html
ReplacePattern http_to_https_filter "http://dev.mydomain.com" "https://dev.mydomain.com"
SetEnv mod_replace http_to_https_filter
I would like "dev" to be anything and be carried over to the replacement string. I need to maintain the mydomain.com since I don't want to switch other site links over to https. I did try:
ReplacePattern http_to_https_filter "http://(.*).mydomain.com" "https://\1.mydomain.com"
But didn't work.
Any help would be greatly appreciated.
Marc
ReplaceFilterDefine http_to_https_filter CaseIgnore intype=text/html
ReplacePattern http_to_https_filter "http://dev.mydomain.com" "https://dev.mydomain.com"
SetEnv mod_replace http_to_https_filter
I would like "dev" to be anything and be carried over to the replacement string. I need to maintain the mydomain.com since I don't want to switch other site links over to https. I did try:
ReplacePattern http_to_https_filter "http://(.*).mydomain.com" "https://\1.mydomain.com"
But didn't work.
Any help would be greatly appreciated.
Marc
Re: Rewrite image tag from http to https
Hello,
Please try using the following syntax:
ReplacePattern http_to_https_filter "http://(.*).mydomain.com" "https://$1.mydomain.com"
If it doesn't work, please check the error.log for possible related records.
Please try using the following syntax:
ReplacePattern http_to_https_filter "http://(.*).mydomain.com" "https://$1.mydomain.com"
If it doesn't work, please check the error.log for possible related records.
- voidinutah
- Posts: 20
- Joined: 25 Sep 2014, 13:59
Re: Rewrite image tag from http to https
I tried using the $1, but it didn't work. Where is the error.log stored and do I need to set anything to record data? I found an error.log in the helicon ape directory in program files, but nothing regarding this issue was recorded.
Also, is there are hierarchy of modules that can be called? If I run this module (mod_replace) by itself with what I wrote earlier, it will convert the links. But when I include my SEO code for URL rewrites connecting to a database, mod_replace stops working. I tried it above the SEO code and below, same outcome.
Also, is there are hierarchy of modules that can be called? If I run this module (mod_replace) by itself with what I wrote earlier, it will convert the links. But when I include my SEO code for URL rewrites connecting to a database, mod_replace stops working. I tried it above the SEO code and below, same outcome.
Re: Rewrite image tag from http to https
Hello,
>If I run this module (mod_replace) by itself with what I wrote earlier, it will convert the links.
>But when I include my SEO code for URL rewrites connecting to a database, mod_replace stops working.
Oh, so you can make it working under certain conditions? This is interesting...
>Where is the error.log stored and do I need to set anything to record data?
You should put the following line into global httpd.conf:
LogLevel 9
and then check the error.log in Ape install folder.
Also please show me all the rules you have in your Ape config files.
>If I run this module (mod_replace) by itself with what I wrote earlier, it will convert the links.
>But when I include my SEO code for URL rewrites connecting to a database, mod_replace stops working.
Oh, so you can make it working under certain conditions? This is interesting...
>Where is the error.log stored and do I need to set anything to record data?
You should put the following line into global httpd.conf:
LogLevel 9
and then check the error.log in Ape install folder.
Also please show me all the rules you have in your Ape config files.
- voidinutah
- Posts: 20
- Joined: 25 Sep 2014, 13:59
Re: Rewrite image tag from http to https
As for the mod_replace, I got it to work with (www|sta|dev) and the $1. But using (.*) has not worked. I'm testing various regex values to get this to work since I would like it to be dynamic for any hostname. And mod_replace doesn't work with mod_SEO with how I have the file set up now. Here is the file:
- Code: Select all
# Helicon Ape version 3.1.0.138
#replace http://*.mydomain.com with https://*.mydomain.com
ReplaceFilterDefine http_to_https_filter CaseIgnore intype=text/html
ReplacePattern http_to_https_filter "http://(www|sta|dev).mydomain.com" "https://$1.mydomain.com"
SetEnv mod_replace http_to_https_filter
#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 %{QUERY_STRING} ^([^&]*&)*page=([^&]+)
SeoCond ${SeoURL:$1|NOT_FOUND} !NOT_FOUND
SeoRule (index\.aspx\?event=courses\.main)\&?(.*)? ${SeoURL:$1}\?$2 [Redirect, Scope=A]
SeoCond %{QUERY_STRING} ^([^&]*&)*page=([^&]+)
SeoCond ${SeoURL:$1|NOT_FOUND} !NOT_FOUND
SeoRule (index\.aspx\?event=courses\.featured)\&?(.*)? ${SeoURL:$1}\?$2 [Redirect, Scope=A]
SeoCond %{QUERY_STRING} ^([^&]*&)*page=([^&]+)
SeoCond ${SeoURL:$1|NOT_FOUND} !NOT_FOUND
SeoRule (index\.aspx\?event=search\.activities\&iID=\d+)\&?(.*)? ${SeoURL:$1}/\?$2 [Redirect, Scope=A]
SeoCond %{QUERY_STRING} ^([^&]*&)*queryString=([^&]+|$)
SeoCond ${SeoURL:$1|NOT_FOUND} !NOT_FOUND
SeoRule (index\.aspx\?event=site\.login)\&?(.*)? ${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 %{QUERY_STRING} ^([^&]*&)*page=([^&]+)
RewriteCond ${OriginalURL:$1|NOT_FOUND} !NOT_FOUND
RewriteRule ^((.+))/$ ${OriginalURL:$1} [NC,L, QSA]
RewriteCond %{QUERY_STRING} ^([^&]*&)*queryString=([^&]+|$)
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]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .? / [R=301,L]
Re: Rewrite image tag from http to https
Hello,
>As for the mod_replace, I got it to work with (www|sta|dev) and the $1. But using (.*) has not worked.
Can you provide the error.log file for the rule with (www|sta|dev) and for the rule with (.*). Remember to enable logging in httpd.conf by putting
LogLevel debug
>And mod_replace doesn't work with mod_SEO with how I have the file set up now.
Does nod_seo work on its own?
Can you explain the whole scenario you are trying to make working and how mod_replace, mod_seo and mod_rewrite are supposed interact.
>As for the mod_replace, I got it to work with (www|sta|dev) and the $1. But using (.*) has not worked.
Can you provide the error.log file for the rule with (www|sta|dev) and for the rule with (.*). Remember to enable logging in httpd.conf by putting
LogLevel debug
>And mod_replace doesn't work with mod_SEO with how I have the file set up now.
Does nod_seo work on its own?
Can you explain the whole scenario you are trying to make working and how mod_replace, mod_seo and mod_rewrite are supposed interact.
- voidinutah
- Posts: 20
- Joined: 25 Sep 2014, 13:59
Re: Rewrite image tag from http to https
I added the logging and found that using (.*) only found the first occurence and not all of them. When I used (www|sta|dev) is replaced all.
If I run mod_replace by itself it works, and running mod_seo by itself it works. I did come across this bug when running both on a small dynamic page. This
[2015-06-02 15:13:09.785] [seo_module] (debug) [/files/images/logos/TCYOD_logo.png] Can't create SeoFilter '/files/images/logos/TCYOD_logo.png' is not TextHtm
Thinking this might be the issue mentioned in the mod_seo docs for content-type, I decided to add content-type to the code above mod_seo such as
RewriteEngine On
SetEnv content-type utf-8
SetEnv mod_seo
However that did not eliminate the bug. Running both on a static HTML file worked fine, so its has to be something with the dynamically created content.
We originally used Helicon Ape to assist with converting the dynamic URLs to SEO friendly URLs, which works beautifully. Now we are adding SSL to the site and wanted to find a more convenient way of changing image tags that the client had entered using the full URL with http.
If I run mod_replace by itself it works, and running mod_seo by itself it works. I did come across this bug when running both on a small dynamic page. This
[2015-06-02 15:13:09.785] [seo_module] (debug) [/files/images/logos/TCYOD_logo.png] Can't create SeoFilter '/files/images/logos/TCYOD_logo.png' is not TextHtm
Thinking this might be the issue mentioned in the mod_seo docs for content-type, I decided to add content-type to the code above mod_seo such as
RewriteEngine On
SetEnv content-type utf-8
SetEnv mod_seo
However that did not eliminate the bug. Running both on a static HTML file worked fine, so its has to be something with the dynamically created content.
We originally used Helicon Ape to assist with converting the dynamic URLs to SEO friendly URLs, which works beautifully. Now we are adding SSL to the site and wanted to find a more convenient way of changing image tags that the client had entered using the full URL with http.
Re: Rewrite image tag from http to https
Hello,
>I added the logging and found that using (.*) only found the first occurence and not all of them. When I used (www|sta|dev) is replaced all.
Hmm, this sounds like a bug. I will ask our developers to check this.
Can you please send the logs for (.*) and (www|sta|dev) rules, so I attached them as a proof.
>I added the logging and found that using (.*) only found the first occurence and not all of them. When I used (www|sta|dev) is replaced all.
Hmm, this sounds like a bug. I will ask our developers to check this.
Can you please send the logs for (.*) and (www|sta|dev) rules, so I attached them as a proof.
10 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 5 guests