the title may seem not clear. now this is my issues.
im using windows which is i need to run the magento with "index.php" on it.
example : "localhost/magentoproject/index.php/test/index/save"
now im using the getUrl function on form like this
<?php echo Mage::getUrl('test/index/save')?>
but after i inspect, the url shows like this
localhost/magentoproject/test/index/save
the url appear is not including the index.php, therefore, magento shows 404 not found.
how i solve this problem ? how to use geturl including the "index.php" on it.
currently im use the hardcode like this on the form
http://localhost/magentoproject/index.php/test/index/save
Go to admin url of your site.
Next go to System > configuration > web > Search Engines Optimization
Then set Use Web Server Rewrites value to 'No'
Related
In the thedigicraft online tutorial for developing dynamic websites, the main example traverses between pages using the browser's response to this: ?page=#. It also works on my project; when I type http://localhost/trying/?page=1, it goes to the project's homepage. I'd like to know how one sets what page opens with ?page=2 and other numbers. In the tutorial's project example, he then uses the _get array to define defaults, but there's no explanation for how his ?page=2 opens up that project's about page, for example. What am i missing - would appreciate any light on this.
In your example page is a GET parameter. The page being loaded is whatever is defined in the server's configuration. In apache it is documentroot. https://httpd.apache.org/docs/2.4/mod/core.html#documentroot
So your page probably is index.php. In that page you could have something simple like:
if($_GET['page'] == 2) {
echo '<title>Other page</title>';
} else {
echo '<title>Home page</title>';
}
Which would display Home Page as the title for every page unless http://localhost/trying/?page=2 is loaded.
You can extrapolate this concept to SQL queries for content loading etc..
Currently I have subdomain.mydomain.com, which redirects to mydomain.com/subdomain(I am using a PHP - codeigniter framework).
But all I want is after redirection url should remain subdomain.mydomain.com instead of mydomain.com/subdomain.
Is there any way to achieve this?
if you like to keep it pure html + php, i suggest you look into the iframe tag from html.
it is basically a browser window within your current browser window. Set the iframe to cover up 100% of your current browser window and set it's url to mydomain.com/subdomain.
what you'll see is that it's displaying content from mydomain.com/subdomain but your url field in your main browser is still saying subdomain.mydomain.com
Write this code in the routes.php file(present in config folder):
$route['mydomain.com/subdomain'] = "subdomain.mydomain.com";
Basically it's logic is
$route['route_you_want_to_show'] = "current_route";
But mind well in codeigniter routes are formed from the redirection of code to controller and its methods.
I need some help to better understand SEO with ajax loaded content.
Here the context:
I have a single.php where content is dynamically generated (with php and an xml database) for each single post.
I load a container of this single.php inside my index.php page via ajax.
Here the working script:
$.ajaxSetup({cache:false});
$(".phplink").click(function(){
var post_link = $(this).attr("href");
window.location.hash = "!"+ post_link ;
$("#ajaxify_container").html("loading...");
$("#ajaxify_container").load('single.php?blog_no='+post_link+' #container');
return false;
});
$(window).hashchange( function(){
var hash = window.location.hash;
var hash = location.hash.replace("#!","");
if(hash != '') {
var post_link = hash;
$("#ajaxify_container").html("loading...");
$("#ajaxify_container").load('single.php?blog_no='+post_link+' #container');
}
else {
$.get(hash, function (data) {
$("#ajaxify_container").html('');
});
}
});
$(window).hashchange();
An example of a link in index.php (when I click on a link I've got in url website.com/#!12) :
<a class="phplink" href="12">Post 12</a>
And in my .htaccess file I added this lines to rewrite properly the url:
Options +FollowSymLinks
RewriteEngine on
RewriteRule /([0-9]+)$ /single.php?blog_no=$1
Everything works fine... (by the way, my single.php is SEO friendly "alone" and works without javascript)
However, by using ajax like this, with dynamic php page, is it still SEO friendly?
I know that ajax is difficult to be crawled. What is the best way to have a good (not the best, something correct) SEO with ajax content?
Regarding the structure of the link, I don't fully understand what google bot will crawl.
Because of the href="12", so the dynamic href="/single.php?blog_no=12".
In the web browser :
website.com/single.php?blog_no=12 and website.com/12 load only my single.php page
website.com/#!12 load my index.php page with a container loaded from website.com/single.php?blog_no=12
Of course I only want that google crawls the hashbang url...
(EDIT: if I open the link in a new tab with right click, it loads the single.php (that I don't want). It seems to be a normal behavior but...I want to prevent it)
Sorry for my English, I'm French.
Dynamically loaded content is generally hard to get right from an SEO perspective. Your description is a little confusing, but I think I have an idea of what you're looking for.
First of all, there are mainly two ways with which Google finds out about pages on your site:
A Sitemap (Google likes XML sitemaps) - A file that tells Google every page on your site to index
Links - Google will follow any internal link on pages it tries to index unless they are marked with rel="nofollow"
There's also links in and some other stuff, but for the purposes of this explanation...lets ignore those.
Anyway, unless you're explicitly telling Google that website.com/single.php?blog_no=12 exists, it's going to have a hard time finding it. To be honest, I'm not sure how Google will handle something like href="12", it may try to follow that link to website.com/12 which may effect your ranking if there is nothing there. So in the end, you might want to add rel="nofollow" to your AJAX trigger links.
A good way to handle AJAX and dynamically loaded content is to make sure fallbacks are in place, for example if you have something like href="single/12 set up to load some content with AJAX, you should also have a fallback page that doesn't use JS/AJAX. This ensures that both search engine bots, and users without Javascript can see that content if it otherwise wouldn't have been visible anywhere else.
Last small tidbit, if you test your links on something like http://www.dnsqueries.com/en/googlebot_simulator.php and they turn up with errors, or blank pages (search engine bots don't use javascript) you should nofollow those links, or setup fallback pages
Nevermind...this is the last thing. You should go a couple steps further with your htaccess rewrite to make your URLs completely clean of query strings. For example website.com/single/blog/12 is better than website.com/single.php?blog_no=12 for both SEO and users.
I wanted to pass the parameters to my PHP page in a friendly fashion, so here's what I wrote in .htaccess file
RewriteRule ^confirm\/(([a-z0-9]).+)\/(([a-z0-9]).+)$ www.example.com/confirm.php?email=$1&order=$2
its working well, and I can get the parameters in PHP using
explode('/', $_SERVER['REQUEST_URI'])
I have 2 problems though,
1- when I submit this page, I need it to go directly to confirmation.php, instead it submits to www.example.com/confirm/example#mail.com/12-HDYF/confirmaction.php !!! how can this be changed.
2- the page was originally working perfectly, but when I type the friendly URL all jquery files give me the below error, which really seems unrelated.
That is because the client (the browser) sees the page it is browsing as www.example.com/confirm/example#mail.com/12-HDYF/ and when it analyzes it and parses the html, it sees it something like:
<script src="jquery.js"></script>
<form action="confirmation.php"... >
So the browser sees relative urls to the page he is at the moment. So if you tell him to search the jquery.js file in the same folder as the one he currently is, he is going to try to download from www.example.com/confirm/example#mail.com/12-HDYF/jquery.js, and the same thing happens when you submit the form.
To avoid this, use absolute URLs (note the leading slash):
<script src="/jquery.js"></script>
<form action="/confirmation.php"... >
If you have your files in a subfolder of the DocumentRoot, put that subfolder at the beginning of the URL.
Change your url structure to avoid ^confirm for both raw and friendly URL, that should make things easier to debug (and avoid loops). This is a guess since you haven't posted your input that fails.
RewriteRule ^orderconf\/(([a-z0-9]).+)\/(([a-z0-9]).+)$ www.example.com/confirm.php?email=$1&order=$2
Not sure if this is possible but wanted to know if htaccess has a trick...
Say I have anchor tag href like this -
Click here
I have changed the URL structure using mod_rewrite but wanted to know if i can hide the actual URL in href using htaccess.
i.e when a user hover over the anchor tag, the browser displays http://example.com/index.php?id=12345 at the bottom. All I want the browser to display is http://example.com/index/12345 without changing it manually on all my pages.
Thanks for the help !
Why don't you change the link to the following?
Click here
As you can change the .htaccess I expect that you own or adminstrate this domain. So it should be possible.
If the links are generated by PHP code, then I suggest you to implement and use a translation function like:
function beautify($ugly) {
// your logic comes here
return $nice; // ;)
}
... and wrap it around the existing code that currently outputs the urls. This would have two advantages:
It's easy and more failsafe to migrate to the new url scheme
From now on you have control over all url related code using a single function
I agree, htaccess can't help you. I guess you'll have to change them manually.
I wish I could be of more help
No. htaccess is for processing input to the web server, not data sent back from the server.
If you use jQuery you could have it rewrite the href when the page loads using something like this.
$(function(){
$("a").each(function() {
this.href = 'some_new_url that you made based on the one in this.href';
});
});