Trouble identifying mixed content on website - ssl

I have tried whynopadlock and then view source scanning for anything with a http absolute address but am completely stuck on identifying where the problem is and could use someones help. It must be a script or something.
The page in question is https://www.uniqbuy.co.uk/orders/list.html
Thanks for any help.

whynopadlock.com reports:
A file with an insecure url of "http://www.uniqbuy.co.uk/" was loaded
on line: 845 of https://www.uniqbuy.co.uk/orders/list.html.
which looks like it refers to this:
<img src="/images/comodo_secure_seal_76x26_transp.png" alt="" />
You could try amending your code to this:
<img src="https://www.uniqbuy.co.uk/images/comodo_secure_seal_76x26_transp.png" alt="" />
Forcing https by adding the following or similar lines to your .htaccess file might be a better solution:
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]

Related

Mod rewrite condition for subdomain with pass through

I wanted to run this by you because I'm attempting to perfect an Apache mod rewrite rule, which works, but I'm going insane because my file paths are breaking.
Basically, I've set up a mod rewrite rule to redirect a subdomain, to a subdirectory in my docroot which contains a static index.html file. Existing rules are listed as follows:
RewriteCond %{HTTP_HOST} ^subdomain\.mydomain\.com$
RewriteCond %{REQUEST_URI} !^/subdirectory/
RewriteRule ^(.*)$ /subdirectory/$1 [PT]
The redirect works fine. What happens though, is my images are breaking. For example, '/subdirectory/img', with the following img tag, doesn't work for me:
<img src="img/some-image.png" />
Same thing happens when I move the image to root, and attempt to call the image directly minus the 'img/' path.
Does my redirect have anything to do with this? Or am I missing something? I was under the impression that using the Pass Through [PT] flag would mean that asset linking would work.
Any advice is greatly appreciated. Thanks for your help!
Mark.
This is because you are using a relative url path for your images. Either use an absolute path starting with a / or add the following base tag in head section of your webpage :
<base href="/">
Related :
Seo Friendly Url css img js not working
Issue resolved. The rule works perfectly, it was just the positioning in the .htaccess file. I moved it directly underneath the following:
RewriteEngine On
Images and JS assets are now loading fine. I also added a missing 'L' flag.
Final working code:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^subdomain\.mydomain\.com$
RewriteCond %{REQUEST_URI} !^/subdirectory/
RewriteRule ^(.*)$ /subdirectory/$1 [PT, L]

Rewrite whole URL with .htaccess

I have an URL with a subdomain that looks like this:
test.my-site.com/
Let's say I want to add forums section to it, which works under:
test.my-site.com/forums/
That works but I want to now rewrite the URL so that every time someone visits the forums section instead of test.my-site.com/forums he sees forums.my-site.com/ in the URL.
I'm trying to do that through the .htaccess like that:
RewriteRule test.my-site.com/forums/(.*)$ forums.my-site.com/$1 [R=302,NE,L]
However, this has absolutely no effect. Any suggestions?
Use:
RewriteEngine on
# Redirect to forums subdomain
RewriteCond %{HTTP_HOST} ^test\.my-site\.com$ [NC]
RewriteRule ^forums/(.*)$ http://forums.my-site.com/$1 [NC,R=302,NE,L]
# Rewrite from forums subdomain to forums folder
RewriteCond %{HTTP_HOST} ^forums\.my-site\.com$ [NC]
RewriteRule ^(.*)$ /forums/$1 [NE,L]
You can create a subdomain forums and use public_html/forums as a directory root for it. Create index.html file in the subdomain directory and use the below html tags:
<html>
<head>
<title>you title goes here</title>
</head><frameset rows="100%" scrolling="yes" border="0">
<frame src="test.my-site.com/forums">
</frameset></html>
try it and let me know any issue
Here is what i suggest
RewriteRule ^mySite.com/([forum|blog])$ $1.mySite.com/ [QSA,L]

HTACCESS how to mod_rewrite the website Asset File paths?

With Apache, how to make a URL (lets say an Image Path) to be actually coming from another location. For example, i have a html page with an URL like:
apple.html, with the original codes inside:
<img src="http://www.myoldsite.com/assets/image/apple.jpg" />
<img src="http://www.myoldsite.com/assets/image/orange.jpg" />
But actually i want this path to be re-written to:
<img src="http://www.mynewsite.com/image/apple.jpg" />
<img src="http://www.mynewsite.com/image/orange.jpg" />
So when i access the apple.html page, the image should be coming from new location, without needed to go and change the actual codes inside the files each.
But actually i'm totally weak in .htaccess rules. When i used like following, it is showing error:
RewriteEngine On
RewriteRule http://www.mynewsite.com/image/(.*) /assets/image/$1 [QSA, L]
I am having thousands of pages like this but I am totally stuck with .htaccess rules.
What am i missing please? Please help.
I assume that both domains point to the same apache instance?
You seem to have switched the arguments for the RewriteRule. The syntax is:
RewriteRule UrlsMatchingThis ChangeToThis [params]
So in your case I would do something like this:
RewriteRule ^/assets/image/(.*) http://www.mynewsite.com/image/$1 [R,NC,L]
This matches all requests where the part just after the tld is /assets/image/(anything).
The flags I have used is
R redirect
NC Ignore case
L Last rewrite rule for this request
You may want to add a condition to the RewriteRule like this:
RewriteCond %{SERVER_NAME} ^(www\.)?myoldsite\.com$ [NC]
RewriteRule ^/assets/image/(.*) http://www.mynewsite.com/image/$1 [R,NC,L]
This will only rewrite your requests if the domain is myoldsite.com, with or without www.
Se http://httpd.apache.org/docs/current/mod/mod_rewrite.html for documentation of the rewrite module.
Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^(image/.+)$ /assets/$1 [NC,L]

.htaccess mod_rewrite subdirectory to URL parameter

I hope this was not asked over and over again before, but I didn't get further to an answer using google, w3schools and so on. So here is my question:
I'm writing a script that creates kind of an index of projects that I have on my homepage and makes a nice list with images and teaser text based on an info file. I mostly have my projects on github and the readme is in markdown so I thought I could dynamically generate the HTML from the markdown of the latest blob from github on demand using PHP so it gets updated automatically.
My directory structure looks like this:
projects
project1
.remoteindex
.info
project2
.remoteindex
.info
index.php
.htaccess
So when just domain.tld/projects/ is requested I get the info from .info and make a nice index of all projects. But if domain.tld/projects/project1/ is request it, I want to internally redirect it to domain.tld/projects/?dir=project1 to do my markdown parsing and so on. But domain.tld/projects/project1/image.png should not be redirected.
This is what I tried:
.htaccess
RewriteEngine on
RewriteRule ^([^/]+)/?$ index.php?dir=$1 [R,L]
I made it redirect instead of rewrite so that I can see what the error is because I just got an 404. The URL that I get redirected to is domain.tld/home/www/web310/html/projects/index.php?dir=project1 so obviously there is something going wrong with the internal structure of the web server an paths an whatever.
I hope you can understand my problem an I would be very pleased if someone could help me, because I'm totally lost on .htaccess anyway.
Edit:
See my answer below for the used .htaccess.
The strange thing is that if I have an index.html in on of the subdirectories, my local web server (Apache with XAMPP for Mac OS X 1.7.3) does not rewrite and the index.html gets displayed, without one it works correctly.But on my real web server that serves my homepage it rewrites both with and without index.html (which is what I want). Any hints on that?
Thanks for all the help so far! You guys are just awesome!
I figured out that a symbiosis of both of your solutions works well for me:
RewriteEngine on
RewriteBase /projects
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} -d
RewriteRule ^([^/]+)/?$ index.php?dir=$1 [QSA,L]
Of course only without [R], this was my fault. (See my question edit for another question please).
You need to add a RewriteBase /projects to the htaccess.
That way the redirect will work properly.
Edit:
RewriteEngine on
RewriteRule ^index.php - [L]
RewriteRule ^([^/]+)/?$ index.php?dir=$1 [R,L]
Following what you ask, this is important not to do a redirect, but let the rewriterule modify internally the URL i.e. the RewriteRule should not end with [R,L] but rather [L] and maybe the "query string append" directive to keep what's after the ? so this should probably be [QSA,L].
Now here's how I'd do to avoid rewriting static files: if it's not a file then (and only then) test it:
# if it's not a file...
RewriteCond %{SCRIPT_FILENAME} !-f
# ... and it's a dir
RewriteCond %{SCRIPT_FILENAME} -d
# ... then rewrite it internally and stop further processing:
RewriteRule projects/([^/]+)(/?)$ index.php?dir=$1 [QSA,L]
And now two hints:
Please try to use the RewriteLog directive: it helps you to track down such problems:
# Trace:
# (!) file gets big quickly, remove in prod environments:
RewriteLog "/web/logs/mywebsite.rewrite.log"
RewriteLogLevel 9
RewriteEngine On
My favorite tool to check for regexp:
http://www.quanetic.com/Regex (don't forget to choose ereg(POSIX) instead of preg(PCRE)!)

"Flat links" with Apache

I'm attempting to convert URLs with GET variables from something like
http://domain.com/?username=john
to
http://domain.com/john
using following the articles here and here.
Using the example in the first article (with a slight modification) - RewriteRule .* index.php - I have gotten that to work. The first problem is, I still want to be able to access the other files in the same directory. So the closest I've gotten so far is RewriteRule index\.php/(.+) index.php?username=$1, which is still not ideal because I don't want the filename in the URL, but there's another problem. index.php is set as the DirectoryIndex, and I have no idea how to match that.
I'm still very much a beginner at configuring Apache, so any help is greatly appreciated.
Try something like that
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !\.php$
RewriteCond %{QUERY_STRING} \buser=\w+
RewriteRule .* user.php [L]
put instead of user.php the name of your script.