I have made small script in php what it does is it gets the url and redirects it to another website only domain name changes rest of the url remains same
here is my code
.htacess
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^?]*)$ /index.php?path=$1 [NC,L,QSA]
index.php
<?php
$url = 'http://justfun4funny.com/';
if (isset($_REQUEST['path']))
{
$url.=$_REQUEST['path'];
}
//var_dump($url);
header( "refresh:0;url=$url" ); ?>
<html>
Please wait while article is being loaded
<h1 style="color:blue;font-size:30"><a rel="canonical" href="<?php echo $url ?>">Click Here to Continue</a></h1>
<div style='display:none'>
<iframe src="<?php echo $url?>"></iframe>
</div>
</html>
the problem i am facing is when i paste this url on my facebook status
http://viralresort.com/2801
it reads all the data for website including image .
http://viralresort.com/2660
but the above url is not recognized by facebook it shows blank data
Hi try entering the URL into facebook Debugger.
https://developers.facebook.com/tools/debug/og/object?q=http%3A%2F%2Fjustfun4funny.com%2F2660
You can also ask Facebook to fetch new information for any URL. I hope this helps.
The debugger is a handy URL, you should keep. Sometimes Information takes time to get cached into facebook. You can additionally add og:type tag to pass information to facebook.
Related
I am trying to open a page on clicking on a link in my codeigniter application. This is the snippet of my attempt
at the controller level this is snippet
//load return policy
function returnpolicy()
{
$this->load->view("return_policy");
}
at the view level this is the snippet
<div class="toggle">
Return Policy
</div>
on clicking on the link it does not navigate to the page. please what am I missing. am new to codeigniter
You should understand the difference between site_url and base_url first
echo base_url(); // http://example.com/website
echo site_url(); // http://example.com/website/index.php
You can rewrite it as follows :
<?php echo site_url('controller/method');?>
In HMVC
<?php echo site_url('module/controller/method');?>
So in your case
Return Policy
you can use the URL helper this way to generate an <a> tag
anchor(uri segments, text, attributes)
So... to use it...
<?php echo anchor('gotopolicy/returnpolicy', 'Return Policy', 'class="toggle-title"') ?>
Possible issue could be of htaccess,
create a file .htaccess in your root CI folder
and add below contents to it
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
Make $config['index_page'] = "";
try to remove class="toggle-title"
or try this
<div >
Return Policy
</div>
How to redirect all URL requests to single php page with simple HTML5 element, but still allow that same page to play video file, through HTML5 element ?
Right now, i have a few half working solutions that would redirect/forbid, but not playing videos (like the source link have also absorbed rule and redirect / forbid).
can someone PLEASE help me with both solutions
HOW TO REDIRECT ALL pages / folders / files, to same single index.php
HOW TO FORBID ALL --||-- and only allow viewing videos from same index.php
My head will explode, i cant read and test them anymore.. :(
More details:
i have VirtualHost: domen.com
folders:
domain.com/player/ // with index.php main page
domain.com/media/ // with forbidden media videos
index.php is simple page with HTML5 tag, that gets file name from argument and loads video from domain.com/media/
URL example: domain.com/player/index.php?video=filename.mp4
<video controls autoplay>
<source src="../media/<?php echo $_GET['video']; ?>" type="video/mp4">
</video>
Some of partial solutions from other stackoverflow posts:
Redirect solution that is not working: its redirecting all to index.php, but also video file is not playing (like i said like its redirecting source too???)
RewriteEngine on
RewriteCond %{REQUEST_URI} !/player/index.php$
RewriteCond %{REMOTE_HOST} !^domain.com
RewriteRule $ /player/index.php [R=302,L]
Doesn't redirect
RewriteEngine on
RewriteRule http://domain.com(?!/player).* http://domain.com/player/index.php [R=301,QSA,NC,L]
If i need to add something more, please tell me,
thank you all !!!
I am having a severe problem and have no clue about what is going on... I will specify the general issue which is causing multiple issues on this Wordpress powered portal.
Steps to reproduce:
Visit the URL: http://gamersgeographic.com/en/ (or any post on this site)
Append #abc or #anything to the URL
The URL tries to resolve for a second and magically deletes the "#" and instead changes to /abc or /anything , which of course does not exist and gives a 404 page not found.
Even if the local anchor with #abc exists, behaviour is the same.
Now, consider the case below:
Visit http://gamersgeographic.com/monster-hunter-diary-1/
Comment link appends a #comments or #respond depending on whether a comment is there or not.
Both the anchors exist on the single post page
Still it redirects after finding them, to /comments and gives 404
Direct URL with #comments works e.g. http://gamersgeographic.com/monster-hunter-diary-1/#comments works but when I change any base URL to #comments, it redirects to 404...
I have tried several combinations with Permalinks, so it is not a problem with that. I even wrote my own Comment link generator in php with just a plain
href="#comments"
but still no luck...
If you need any further information about any function's code in theloop.php or anything please let me know.
Thanks in advance !
Regards
The contents of .htaccess are as below:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
This is not a PHP issue, it is Javascript: it is evident when you reproduce it, and you can test it by disabling Javascript and adding #comments at the end of the URL; it will work.
Now, I have done some work for you, and the culprit is a Javascript file aptly named hashchange.js. Look, for example, at this line:
function second_passed() {
if(current_page!=location.href {
get_page_by_hash(location.href);
}
setTimeout(second_passed,1000);
}
Which explains why you see it “working” for a second.
And here is the redirect:
jQuery(window).hashchange(function() {
var link = window.location.hash.replace("#", "");
get_page_by_hash(link)
});
Note that hashchange is a method for event handling available in jQuery Mobile.
<link rel="canonical" href="URL OF YOUR HOMEPAGE HERE>
add this in your header.php in <head></head> section and then try . it shouldn't be giving 404 error !
The way that page bookmarks are used is, as you know, the href="" of an anchor points to an #some-place. In order for this to happen #some-place must be the id of the element within the page you wish to go to.
For example:
http://gamersgeographic.com/monster-hunter-diary-1/#respond
should take you to the element with id="respond" in that page.
If the element with that ID doesn't exist you won't be able to travel to it, and may be the reason it results in a 404 Not Found. However, if the element does indeed exist on the page with the proper ID and it still redirects to a 404 then you may want to check your web server configuration to make sure it isn't filtering the # in some way.
I have showing the ad banners in .../openx/banner.php
Each Banner I had set the Banner Link.
After clicking the Banners the Page is redirected with the following URL.
.../openx/www/delivery/ck.php?oaparams=2__bannerid=1__zoneid=1__cb=5b97a864fe__oadest=http%3A%2F%2Fwww.google.com
Here is the root URL : openx/
I want to remove the last segment that is oadest=http%3A%2F%2Fwww.google.com when the page is loaded.
Please anyone help me...
Thanks...
Assuming this string is always at the end of your url, try putting this in the appropriate place on your .htaccess file:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^(.*)oadset=(.*)$
RewriteRule ^/?ck\.php$ /ck.php?%1 [L]
hello i have an anchor on my site. by calling my site the url will be:
http://site.com/page.php
by clicking a button the url will display an url that i would like to hide:
http://site.com/page.php#1
now i have found out that i can change this by using mod_rewrite tool. i tried this rule without success:
RewriteEngine On
RewriteCond %{REQUEST_URI} ^(.*)\.html$
RewriteRule ^.*\.html$ %1.php [L]
for calling the page as html or php and to hide the #1 behind the .php
RewriteRule ^(.*)$ ./php#1=php$1
i really would appreciate if there is someone who could give me advise on how to solve this. thanks a lot.
You cannot achieve this via mod_rewrite.
URL after # are not passed through server.
If you still want to achieve this, you may want to look into doing it via JavaScript:
Check this out
JavaScript:
function scrollHere() {
// Scroll to the anchor
//(you may need to look for some script to achieve this)
return false; // to prevent URL overwriting
}
One such script is this jQuery.scrollTo.
The hashtag is never sent to the server, thus you simply cannot create a rule, that based on it.
You can do something like this to remove # tag.
Your text.
So when you write "javascript:void(0);" in href attribute of a tag and thats it.
HTML
<a href='page'>Home Page</a>
<a href='page/1'>Page 1</a>
<a href='page/2'>Page 2</a>
<a href='page/3'>Page 3</a>
Rewriting as
RewriteRule ^$ page.php [L]
RewriteRule ^([a-z]+)/?([0-9]*)/?$ page.php?index=$2 [L]
And check for index in php
<?php
if (isset($_GET['index']))
{
$pageNo =$_GET['index'];
}
//based on page NO display contents
?>