Despite many topics on Open Graph, i cant seem to find anything that covers my specific problem.
I have built a site for a client which consists of a number of static html pages. since completion the client wanted social buttons added and so i have inserted all of the necessary Open Graph protocol meta tags.(see below)
<meta property="og:title" content="site name" />
<meta property="og:type" content="website" />
<meta property="og:url" content="http://www.mydomain.co.uk/page" />
<meta property="og:image" content="http://www.mydomain.co.uk/images/image.jpg" />
<meta property="og:description" content="page description" />
When testing a selected page on the Facebook Object debugger, my included meta tags don't seem to be recognised. I think the problem could be caused by the .htaccess file i have included to remove the need for the '.html' and '.php' ...see below; I believe this is the problem as when i test my site witht he .html it seems to work just fine (so long as .html is included in the "og:url" meta tag.) but if not, all kinds of problems occur, and the description Facebook pulls up is actually the text from my css file..?
<Files .htaccess>
order allow,deny
deny from all
</Files>
ErrorDocument 404 /error404.html
Options +MultiViews
RewriteEngine on
RewriteCond %{HTTP_HOST} ^([^.]+\.co.uk) [NC]
RewriteRule (.*) http://www.%1/$1 [R=301,L]
There may be something simple im missing here but it seems to be getting the better of me. Any help would be amazing! Thanks in advance.
Related
Htaccess is not my favourite and please be kind enough to help me with this.
Ex. Www.domain.com/about.php shows the site with styles rightly. In the browser if add www.domain.com/about.php/ or www.domain.com/about.php\ all the styles are ruined and page is distorted.
How to eradicate backslash and slash after file extension in htaccess.
Appreciate your help
Rgds
It is path/to/style.css but when you add / after about.php , the included file path will be changed to about.php/path/to/style.css so nothing will show up.
To solve this issue add this <base href="/"> between <head> Tags in order to keep a base fixed :
<head>
<base href="/">
</head>
Update:
As per your comment that you want to add rules in .htaccess for this case , try this :
RewriteEngine On
RewriteRule ^(.+)\.php/(.*)(\.css)$ $2$3 [L]
I've been trying for at least 4 hours to fix this problem on my own and have scoured through several hundreds of Stack Overflow pages and other forums in search of a solution, but I can't seem to solve this simple problem.
The contents are arranged as follows:
-- index.php
-- js
- script.js
-- css
- style.css
-- images
- image.png
In the website, I needindex.php?dept=foo to be rewritten as dept/foo. This works with the following RewriteRule:
RewriteRule ^dept/(\w+)/?$ index.php?dept=$1 [NC]
But then the CSS, JS and images won't load any more.
The CSS and JS files are currently are currently included as follows:
<link rel="stylesheet" href="css/style.css" />
I tried changing the URLs to have absolute paths (i.e. /css/style.css too`, but that didn't fix it either).
How can I correctly fix the problem?
Based on your comment have this rewrite rule:
RewriteEngine On
RewriteRule ^dept/(\w+)/?$ index.php?dept=$1 [NC,L,QSA]
Then add this just below <head> section of your page's HTML:
<base href="/live/" />
so that every relative URL is resolved from that base URL and not from the current page's URL.
You can keep your CSS path as:
<link rel="stylesheet" href="css/style.css" />
I need some simple help with my htaccess file, thank you in advance.
I have a number website URLs, such as:
www.site.com/index.php?page_path=solutions-overview.html
www.site.com/index.php?page_path=solutions-a.html
I want to use the RewriteEngine to change the above links to the following respectively:
www.site.com/solutions/overview
www.site.com/solutions/a
Below is the .htaccess code I am using:
RewriteEngine On
RewriteRule ^solutions/overview index.php?page_path=solutions-overview.html
RewriteRule ^solutions/a index.php?page_path=solutions-a.html
This works, however all of my images, CSS files and JS files no longer load because the page is trying to fetch the wrong URLs. For example "/images/blah.jpg" is instead loading as "/solutions/images/blah.jpg".
How can I modify the htaccess code to prevent relative URLs from changing?
Thank you!
Add this line <BASE href="http://www.yoursitename.com/"> to your page inside the <head> tag as follows:
<head>
<title>Your site title</title>
<BASE href="http://www.yoursitename.com/">
....
</head>
I have effectively used the rewrite rule to change my url from /teams.php?team=New York Yankees&year=2012 to teams/New York Yankees/2012.
My .htaccess file contains the following
RewriteEngine On
RewriteRule ^teams/([^/]*)/(^/]*)$ /teams.php?team=$1&year=$2 [L]
However, with this rewrite rule currently in effect, none of the external CSS and JS files will load. I've tried putting the following rewrite condition before the rewrite rule with no luck
RewriteCond %{REQUEST_URI} !^/(css/js)/
Almost all of my files have the following link to the external stylesheet.
<link rel="stylesheet" type="text/css" href="css/stylesheet.css" />
Any ideas what I'm doing wrong here?
Thanks
You will have to use full paths when linking to your stylesheets, not relative paths like you have now. With the rewrite rules in place they become relative to the pre-rewritten URL.
For example, change:
<link rel="stylesheet" type="text/css" href="css/stylesheet.css" />
to:
<link rel="stylesheet" type="text/css" href="/css/stylesheet.css" />
The reason they are not loading is because the browser is trying to access:
http://yoursite.com/teams/New York Yankees/2012/css/stylesheet.css
when you link to css/stylesheet which of course does not exist.
I've worked-around the solution to transform all uri to one page via ErrorDocument.
The reason behind this is to send Files AND folders (nice urls) to one page. However, I need the URI string to be sent to index.php?uri=string . Is this possible via ErrorDocument, or how do I do this?
So I need to rewrite the
http://www.something.com/games/specific-game
to
http://www.something.com/index.php?uri=/games/specific-game
Is this possible at all, if, how?
If your server supports server-side include (SSI) then you use the following 404.shtml as your ErrorDocument:
<html>
<header>
<meta http-equiv="Refresh" content="0; url=/index.php?uri=<!--#echo var="REQUEST_URI" -->">
</header>
</html>
EDIT: there is a simpler way: create a PHP file as your ErrorDocument and you can do anything under the sun in it! :)
EDIT2: you can access the original URI using $_SERVER['REQUEST_URI']
EDIT3: heck, if you are just redirecting to index.php on the same host, you can just set that index.php file as your ErrorDocument and detect if the request is redirected from 404 error by checking if $_SERVER['REDIRECT_STATUS'] == '404'