Open URL but point to main directory - javascript

I'm going to do a website with AJAX.
At the moment i change my main content with '#':
e.g. example.com/#home --> example.com/#site1
I managed it to change the content at the moment the hashtag changes.
But now i want to use a method i know from google.
example.com/home/ --> example.com/site1/
I know so far how to change the URL without reloding the page. (Modify the URL without reloading the page) My problem is if the user reloads the site or uses the navigation buttons, he will land on example.com/site1/index.php and not on example.com/index.php.
BUT it is important that the data (site1) is send to the script.
I hope you can understand my problem.

You need something on the server side (.htaccess for example) to return your index.php no matter what the url is.
See here for a possible solution: https://stackoverflow.com/a/8392502/1030527

Related

Problems at redirecting specific pages in Tumblr

What I need to do is redirect my main tumblr blog to a static homepage.
So that when someone goes to my blog is redirected to the static homepage instead of all the posts.
The process of redirecting might seem like making it harder than it needs to be, but other solutions have not worked. I was able to do the static homepage by changing other parts of the code (without the need of redirecting pages) but it made all the posts disappear, even when looking at their tags. (See more detail into this solution I tried in this question)
So since that doesn't work, all I can think of now is to redirect my tumblr to another one to be the homepage. The new tumblr blog with the static home page is "no-poo-es-inicio.tumblr.com" and the links in the navigation bar go to the actual tumblr blog where I will be posting. (This new blog has the code that created a static homepage and hid all the posts)
To do the redirecting I have tried:
<script type="text/javascript">
if(location.href == 'http://no-poo-es.tumblr.com');
location.replace('http://no-poo-es-inicio.tumblr.com');
</script>
And it works at redirecting, but it redirects everything that starts with my blog url, meaning "no-poo-es.tumblr.com/tagged/foto" or "no-poo-es.tumblr.com/post1" are also redirected to the new url, which I dont want since the new url is only supposed to be the homepage.
I need to find a way so that only my blog url is redirected, but when it has anything added afterwards it won't redirect.
Don't know much about coding so if you have a solution that is not html or javascript, can you also tell me which code to add to install whatever needs to be installed, if even, and how to properly write it in the html code. Thank you very much in advance.
Tumblr has help for this here.
Otherwise, I'm unsure whether Tumblr will have user-support for JS redirection.

Linking to the end of another page in which i have no access to the source of

The website i'm trying to link to is pretty much a text document (see below), i'm trying to link to the last line preferable, highlighting it would be ideal but a link to the end of the page would work.
I've tried various code snippets, but as i have no access to the code of the page i cannot create anchor in the target page and link directly to that.
if i can get the following code to run on the page once i have navigated to it, i believe that would solve the problem, but my JS knowledge does not extend that far
window.onload=toBottom;
function toBottom()
{
alert("Scrolling to bottom ...");
window.scrollTo(0, document.body.scrollHeight);
}
i am linking using the following code
`— Alan Turing `
http://www.loebner.net/Prizef/TuringArticle.html
I would deeplink and find an ID on the remote page and link directly to that so for example
www.loebner.net/Prizef/TuringArticle.html#ELEMENTID
However if the page does not have an element at the bottom with an ID then might be a problem, do you have access to that page to add an ID?
Cleanest solution was contacting the site administrator of the site and setting up a mirror on my server of the original file and adding an #ID to the element i wanted to deeplink to and linking to the #ID from within my webpage
href="<c:url value="loebner#ID"/>"

Change URL in link after code has been output

So, I have a dotNetNuke site that was developed by someone else. These developers are not available to respond to requests as fast as I need in this case, and I have to fix something on a customer's site ASAP.
Somehow, the Home link in the site's side nav is pointing to the Contact Us page. Not sure how this was done, but I have limited access to the backend of the site (what's there is a mess anyway).
I'm looking for a way to change the URL of the Home nav item only from http://www.mywebsite.com/subdir/ContactUs/tabid/2530/Default.aspx to http://www.mywebsite.com/subdir/. I've tried swapping out the text with JavaScript to no avail. Does anyone have any ideas?
Any help would be greatly appreciated. Let me know if you need more info.
As lostPixelx suggest and seeing it kind have some hack that DotNetNuke do to the the link work. Please add the following to a javascript
$(function() {
$('#tddnn_dnnMENU_ctldnnMENU2529').click(function(){self.location="http://www.mydomain.com/subdir/"})
});
I would recommend you go in to the PAGE SETTINGS for the HOME page via the Admin/Pages (page management).
From there, on the last "tab" in the settings, towards the bottom, you can find a "URL" or "Navigation" Section, make sure nothing is selected there, then save the page settings.
Running this Jquery code will remedy your issue... but it seems like your site has some issues that you should address, not bandage with JS.
$('h1.logo a').attr('href','http://www.mydomain.com/subdir/');

jQuery+ AJAX + Help Hiding This Content

First of all: I hope the following question is not too generic.
I have a small problem and I cant think of a good solution and I was hoping some1 here is able to help me.
This is my situation:
I am using AJAX to dynamically load pages. My main site is index.php and once I click on a navigation link, the AJAX script replaces the content of index.php with new content and adds a hash tag to the URL. For instance:
I click on the link to about.php, the script adds #about.php to the URL and loads content from about.php into index.php. It works great :) However, there is a small issue that I would like to resolve:
Lets say we start by navigating to index.php#about.php directly - this means the content of index.php is visible for 2,3 seconds and than gets replaced with content from about.php. And I would like to avoid that.
I came up with a few ideas, but they are all not really great:
1) Hide content -> than make AJAX call -> on completed AJAX show content again
Downside: The content is still visible for a second.
2) Hide content with CSS and show it after AJAX call
Downside: This would work perfectly, but users without Javascript (and the GoogleBot) will see an exmpty page only.
3) Use an empty index.php and put the content of it in main.php and automatically load main.php via AJAX on page load.
Downside: Would work too, but again, users without JS and GoogleBot will just see an empty page when the visit index.php
Thats all I can think of and all three solutions are not good, because I am worried the SEO value will dramatically decrease when I have an empty index.php (I could accept that users with no JS get nothing to see).
p.s. I read somewhere that when you have display:none in an external css file and block it with robots.txt, GoogleBot wont know the difference, but I am worried thats maybe not the case? Any1 got some experience?
Edit: I guess my whole question comes down to this:
Do you think hiding the whole content of index.php with CSS (and than show it with JS), will be a huge no-go for SEO or will it be okay with GoogleBot (afterall the content is still in the source, but not visible to the user)?
If you used query strings instead of the hash you could have index.php load the correct content at the server level.
A plugin like history.js can help you push URLS to the browser so that you still get your ajax browsing.
Wow where to start...first of all the page 'blink' I'll call it is 2-3 seconds for you but it is completely dependent on the users computer, how fast it executes the javascript, and how fast the AJAX call returns so you could have a much larger delay.
Second I wouldn't worry about Googlebot seeing any of the ajax content. While it's true googlebot does try to fiddle with some javascript it won't make the ajax call like a normal browser would. I'd be very surprised if Googlebot ever saw any of your Ajax loaded data.
Googlebot does a fantastic job of figuring out what content is delivered via html/css to a user when they visit your page. It also figures out if something is displayed or not and does a good job of deciding if that content is just stuffing or is something that really matters.
You're worried about what someone without javascript will see when the entirety of navigating your site is based in javascript. This doesn't seem to reconcile.
You've got PHP available. My suggestion is to forgo the AJAX stuff you're trying to do and do it in PHP. You can just as easily script the same behavior in PHP as you can in AJAX.
SEO NOTES:
If you're looking for solid SEO results I suggest making the static (non-javascript version) page as SEO friendly as possible. I like to 'pick the low hanging fruit' like making sure the page has one and only on H1 and that it has the most important keywords in it. seomoz is one of the best sites I've found for seo information.

URL Hash w/ Javascript

I am trying to rewrite a URL from something like this:
http://www.asdf.com/index.php
to
http://www.asdf.com/#welcome
http://www.asdf.com/#test
Right now, the welcome/test pages are sliders on the page and it moves it around without changing the url from index.php to welcome/test. How can I directly link these sliders?
Here's an article on preserving bookmarkability and the back button with Ajax.
http://onjava.com/pub/a/onjava/2005/10/26/ajax-handling-bookmarks-and-back-button.html
You would use a bit of JavaScript on the page to detect which (if any) sliders are in the URL and then triggering the action that exposes them.
you can not modify what the user has put in the url, you want to make sure your links say that. The only way you can change the url is with a redirect. you would need to use something like .htaccess files on apache to rewrite the .php urls to 'seo friendly' urls.
browsers auto detect the parts after # and go to that part of the page (if it exists). It does not do anything for the server though.

Categories

Resources