From HTML to PHP, referencing - .htaccess

I have a website already in place with only html pages that all well referenced. I wanted to improve it and add some php.
But the page is now named index.php.
So I could use something like this in my .htaccess
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)\.htm$ $1.php [nc]
By doing this will I lose the referencing of my html pages by google ? Do I go back to the very begining ?
What will happen if people search for index.html ?
Thank you in advance for your help !

Say google to update it's data, I see that in wordpress exists option that say google when you and new page
Make in htaccsss possibility to find the same page with .htm and .php.
Google with time may be correct the link in his search result to your site to .html.
Make and send new site map to google robot
https://www.google.com/webmasters/tools/submit-url?hl=ru.

Related

htaccess auto redirect while attemp to view direct content

I am currently administrating some art website that contains lots of photos and other content files and it bugs me that ppl find a way around scripting and are accessing stuff directly, they download our copyright protected materials.
I was thinking about htaccess file that do the following:
someone type in address directly to the browser: http://www.mydomain.com/photos/photo.jpg
htaccess triggers and instead of showing the content - it redirects right away to: http://www.mydomain.com/ (this is important to do redirect before picture is displayed)
redirect is extremely important not just some preventing without redirect, but if someone attempts to use sowftware to download content via providing link to it then it rejects request
my knowledge about htaccess is really thin i could use a help on this one
This should work:
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://www.mydomain.com/ [NC]
RewriteRule .*\.jpg|gif$ /nolinking.html [R]
If you try enter http://www.mydomain.com/photos/photo.jpg it will redirect you to http://www.mydomain.com/nolinking.html, but it will allow images to be loaded on pages if they are linked to,

Changing a website domain and redirecting

We're moving a fairly large website from domain.one where it's been for a long time onto domain.two. If people still find links for domain.one we want them to redirect to an appropriate place on domain.two (if possible).
Domian.one is no longer required after the switch. I don't know anything about moving an entire domain so could use some advice on the best way to go about switching whilst retaining the SEO gained over the years.
Any help is appreciated.
Many thanks
Put this in an htaccess file in your root web directory. It will forward your users, and search engines, to the new URL on the new domain.
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]
ADD THE FOLLOWING LINES as posted by John .
Also log in to google webmaster tools->configuration->change of address
and change your url ther so that seacrh engine results are also changed.
THIS iS VERY IMPORTANT

.htaccess invisible redirect to page within subfolder

I've tried many options in .htaccess without success. What I want to do is this:
I have Wordpress residing in its own folder, like this: site.com/folder
I want all users visiting site.com to be redirected to site.com/folder/page but in such a way that the URL doesn't change in the browser. All other URLs, such as site.com/folder and site.com/folder/page1 etc shouldn't be affected.
How to do this, in as SEO-friendly way as possible?
Thanks everyone.
You can't redirect a user to a other page from serverside without to show this to the use.
But if you need, you can use the HTML tag <frame> http://www.w3schools.com/tags/tag_frame.asp
But the bad side with this is the use always will be show "site.com" and not the real page.
But I think the best way is to proxy the result, in Apache you can do this by something like this.
RewriteEngine ON
RewriteRule ^/$ folder/page/index.php [L]

Redirect to a page if URL contains string

My business has been bought-out. As such we are re-branding and changing the URL's of our sites. I have 2 URL's pointing to one web server (the old, original URL and the new URL) and what I would like to do is have script on my pages to see if my user has visited the old URL. If they have I would then like them to be redirected to a particular html page to tell them that the site has changed and that they need to update their favourites. I do not want the redirect to be automated.
Basically any time the old URL is detected I would like them redirected to the redirect page to inform them
IF URL contains 'dls.myOLDwebsite.co.uk' THEN REDIRECT to: 'dls.mywebsite.co.uk/redirect.html'
The reason I would like to do this is because if the user is going to the new, correct address (example; dls.myNEWwebsite.co.uk) then I don't want any redirects or messages.
Can anyone assist?
I believe you're looking for this.
You need to add the following to the .htaccess file of your site
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REMOTE_HOST} dls.myOLDwebsite.co.uk ^
RewriteRule ^/$ http://dls.mywebsite.co.uk/redirect.html [R=301,L]

Rewrite URL to remove first page pagination using htaccess

I have an paginated list of articles and my search engine is indexing the first page twice as /articles and /articles?start=1.
I want to write an .htaccess rewrite rule to rewrite any requests for /articles?start=1 to /articles to stop this from happening.
There are a couple of other article based paginated lists on the site, so i need to match just the parameter rather that the full url, so that the rule will work on thse urls also.
Thanks for your help!
Try this:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} \/articles\/
RewriteCond %{QUERY_STRING} start=1
RewriteRule (.*)$ /index.php\?
I am assuming articles is a directory.
A bit of a necro, but I just found this question via Google when looking for something else.
Recently, Google offered up way more control over how URL parameters affect their indexing of your site. Go to Google Webmaster Tools and set up your site.
Google will crawl your site and add a list of URL parameters its aware of (and I beleive you can add your own to the list). You can specify how the URL parameters affect your page (pagination, filtering, internal etc) which in turn tells Google how to index it.
In this case, you'll be able to say that start should be either ignored, indexed only once, or treated how you see fit to make sure it only appears how its meant to in the index.
This helps Google and also helps you, so its entirely win-win.

Resources