Rewrite base url to show content of cms page - url-rewriting

Trying to rewrite a base url e.g http://beta.mydomain.com to http://beta.mydomain.com/cms/index.cfm/new-home but want browser to show base url not the cms url.
Im trying this in isapi httpd config file:
RewriteRule ^$ /cms/index.cfm/new-home [NC,L]
but it simply redirects to http://beta.mydomain.com/cms/index.cfm/new-home
which is correct except that the browser must show http://beta.mydomain.com/ not the cms part.
We are using IIS 6 with isapi module installed. Thats the only thing I know about the server (but I have access to server). Is that possible? If not then what other options do I have?

I have an idea: Load http://beta.mydomain.com/cms/index.cfm/new-home in an iFrame.
For example if someone browser to base URL i.e. http://beta.mydomain.com/ then load http://beta.mydomain.com/cms/index.cfm/new-home page in iframe.
It should be like a condition at top of your index page.
if (only baseURL) {
iFrame: Load http://beta.mydomain.com/cms/index.cfm/new-home
}
Hope this help :)

Related

Google Ajax crawling is failing

I have a php ajax website that serves pages to my users like
http://www.example.com/ => this has all the individual page contents like listing
http://www.example.com/#!page1-uid => has page1 contents, uid is the unique mongoDB identifier for that page
http://www.example.com/#!page2-uid => has page2 contents, uid is the unique mongoDB identifier for that page
I want google to crawl my website to index all of about 200+ pages but none of them are getting indexed
I pretty much followed and understood the google ajax crawling methods but not sure where/what i am still missing.
Here is the setup:
.htaccess
RewriteCond %{HTTP_USER_AGENT} (googlebot|yahoo|bingbot|baiduspider) [NC]
RewriteCond %{QUERY_STRING} _escaped_fragment_=(.*)$
RewriteRule ^(.*)$ botIndex.php?QSA=%1 [QSA,L]
botIndex.php
$var1 = $_REQUEST['QSA'];
checks if QSA is set, if so, serves the individual page1/page2
else gives out the default home page that has the listing of all the page links
When I tested using GWT ( "fetch as google" ), here is the pattern i observe
a) www.example.com/ => it gets redirected to botIndex.php and returns me all the links (default view) just as expected
b) www.example.com/#!page1-uid => redirects to the botIndex.php and returns me all the links but ideally it should return the actual page content instead of the home page contents (not sure GWT has the ability to ask for _escaped_fragment_ to mimic googlebot)
c) www.example.com/?_escaped_fragement_ => GWT returns "Not found" error
By adding few echo in the botIndex.php, What i suspect is none of the above requests shows that the "_escaped_fragment_" is caught
hence my script botIndex.php does not get the value of the QUERY_STRING (QSA) to serve the page1/page2 individual pages instead always
defaults to home page showing all the page listing.
I tested the URL's directly for botIndex.php like
a) http://www.example.com/botIndex.php?_escaped_fragment_=QSA= (returns all the links )
b) http://www.example.com/botIndex.php?_escaped_fragment_=QSA=page1-uid (returns the actual page details)
What am i still missing ?
I strongly believe the .htaccess has the issue which is not possibly passing the QSA to my script.
Please suggest.
UPDATE: I am still stuck. Anyone can help me with some pointers ?
Evidently, you have problem with preserving GET parameters during rewriting. Try to debug you .htaccess directives.
Another option is to create one entry point for your php app, just like all modern frameworks do. And implement all the logic (serving html content for bots) in your php app.

how to redirect a link in my website to an external link?

I have provided a link from my web site in my andoird app which is:
www.mysite.com/support
And i want this link to be redirected to:
www.anothersite.com
i have already tried com_redirect and entered support as source and http://ww.anothersite.com but i dont get any redirects and i get 404 error.
I am running Joomla 3.x and i want to know how i can do this with URL rewrites and no external components.
It seems not possible to do it within the Joomla backend (i tried many combination of menu items and the redirect module).
For sure you can write your redirect directly in your .htaccess (if you are using it) like this:
RewriteEngine On # Turn on the rewriting engine
RewriteRule ^support/?$ http://www.anothersite.com/ [R=301,NC,L] # Permanent Move
or
RewriteEngine On # Turn on the rewriting engine
RewriteRule ^support/?$ http://www.anothersite.com [R,NC,L] # Temporary Move
More info about URL rewriting and .htaccess are here: http://www.addedbytes.com/articles/for-beginners/url-rewriting-for-beginners/

Change URL in address bar but keep on same page

Is it possible to rewrite a url so that the page stays the same and the url itself is chanaged ?
E.G.:
I have a page at www.example.com/sales
I want this url to appear in the address bar as www.example.com/sales_and_repairs
I am NOT trying to redirect a page at www.example.com/sales to ANOTHER page at www.example.com/sales_and_repairs ....There is only ONE page - it is just the URL I am trying to change so that if a person types in www.example.com/sales, they will go to that page but the URL in the Address bar will change to show as www.example.com/sales_and_repairs
Is this possible with rewrite rules ? Anytjhing I have looked up appears to suggest that you have to be redirecting to a second page - but that is not what I want to do - I just want to change the actual URL.
Any advice please ??
If you want to redirect www.example.com/sales_and_repairs to www.example.com/sales permanently you can do it with an .htaccess file.
First of all, you'll have to enable mod_rewrite in apache.
Then add the following to your .htaccess file :
Options +FollowSymlinks
RewriteEngine on
Rewriterule ^http://www\.example\.com/sales_and_repairs$ http://www\.example\.com/sales [R=301,NC,L]
This method allow you to have only one file behind the two urls.
However if you want to modify the url after a user's action, you can do it with the answer given by Sparda above.
Seems you can achieve this with javascript :
location.hash = 'newurl';
But this will add an anchor to the url.
Some earlier features of html5 can do this but are not really supported yet :
history.pushState(data, 'title', 'newurl');

htaccess redirect raw image viewing

I'd like to redirect any image that is viewed directly to a handler page:
if http:// mysite.com/pics/filename.jpg (or www.)is in the URL
then redirect to http:// mysite.com/pics/index.php?img=filename.jpg (no www)
But if the image is being called by a webpage or a mobile html5 app anywhere then it should be served per normal.
So if mypage.html contains an img tag with the direct photo in it it will be shown in that page. But if http:// mysite.com/pics/filename.jpg is the url then it should redirect. In other words if the file is being viewed directly it should redirect to the wrapper page, but if it's already in a wrapper page (anywhere) it shouldn't redirect.
I've seen various redirect code but none that that references the visible url for the if statement, so I don't know how to do this. And the ones I've found and tried don't work, either redirecting all requests, or not doing anything
Thanks!
This will take care of people hotlinking to images on your site for you:-
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?mysite.com [NC]
RewriteRule ([^/]+)\.(jpg|jpeg|png|gif)$ pics/index.php?img=$1.$2 [NC,L,R]
As for your mobile HTML5 app you are going to need some other way to identify it to your web server. So you are going to have to see what referer that says it is when it is asking for images. It should be pretty easy for you to write a PHP script to tell you that, then you just need to add to the above code to include that.
Simon

joomla - SEO settings and mod_rewrite

I'm using Joomla 1.5.14 and I configured SEO as in the following image
Now I need to map a few old URL to the new site
let's say that I need to map htp://mysite/old.html to the new Joomla page
http://mysite/index.php?option=com_content&view=article&id=32&Itemid=70
I added in my .htaccess file the following
RewriteRule ^old\.html$ index.php?option=com_content&view=article&id=32&Itemid=70 #works!!
this works fine, but if I use the SEF URL in .htaccess (let's say the above page can be reached with htp://mysite/contacts.html), I obtain a 404 error
RewriteRule ^old\.html$ contacts.html #this does not work
Now the question:
Is it possible use SEF URLs in RewriteRule? where am I wrong?
thank you in advance
stefano
I think the problem is because Apache rewrites old.html to a page that doesn't actually exist, but rewritten in a different rule.
If you truly want to "rewrite" - in other words, have the page stay as old.html in the browser - then you don't need to do anything.
However to avoid duplicate content it's probably better to do a 301 redirect:
Redirect 301 old.html http://yoursite.com/contact.html
(You may need a forward slash at the front of old.html)

Resources