For some reason the urls in one section of our site were changed from php to html some time ago.
I recently setup a Google Webmaster account and noticed the 'old' php pages (20,000 of them!) are appearing as Crawl Errors (403 Forbidden error).
Are these the 'old' urls that Google crawled still showing in the index? If so what can I do? Is the best thing to setup a 301 redirect for all these urls, however what the best way of doing this when all thats changed in the url is the file extension (the php and html files are in the same directory) - is it possible to setup a 301 to redirect one file extension ie php to html within the same directory?
To fix this you definitely want to setup 301 redirects from the old URLs to the new URLs. If you use Apache you can do this by placing a .htaccess file in your root web directory with this snippet in it:
RewriteEngine on
RewriteBase /
RewriteRule ^(.*).html$ $1.php [R=301,L]
Related
I am trying to create 301 redirects from a silverstripe subdirectory to a new site/subdomain on different server, can't seem to make it work!
So need www.researchnutrition.com.au/practitioner redirecting to www.practitioner.researchnutrition.com.au
along with a number of other urls within the practitioner subfolder specified to new pages on new domain.
Have tried several combinations or rewrite/redirect rules but nothing seems to be taking effect.
Also should the .htaccess file where I make the changes need to sit within the root folder or within the /practitioner folder.
Thanks so much in advance.
You can use .htaccess file in the practitioner folder:
RewriteEngine on
RewriteRule (.*) http://www.practitioner.researchnutrition.com.au/$1 [R=301,L]
Another option is just creating a redirection page in the cms and redirecting that to an external url (which is, despite the option saying "redirect to internal page", possible).
I have my own domain:
http://cesarferreira.com
and I wanna make
http://cesarferreira.com/github
point to
https://github.com/cesarferreira
Without having to make a /github/ folder with an index.html with a redirect for each page I own (facebook, twitter, pinterest, etc)
Is there a way like for example htaccess catchig *.com/github and pointing to a given static url?
Thanks a lot
If your document root serves -
http://cesarferreira.com
you can put a redirect in .htaccess like -
Redirect /github https://github.com/cesarferreira
Take a look at URL rewriter 'http://httpd.apache.org/docs/2.0/misc/rewriteguide.html'. That should be able to do everything you want and more.
As long as it is enabled in apache then you can use it in .htaccess files also.
You can use mod_alias:
Redirect 301 /github https://github.com/cesarferreira
Or if you only want github to point only to the folder:
RedirectMatch 301 ^/github https://github.com/cesarferreira
You can put that in the htaccess file of your document root.
Have ran into an issue when adding WordPress multisite and then subsequently moving some old posts from the main site to a new subdomain. Those moved posts (their text) carry over fine (using one of several methods available) the problem comes when the front page of the new subdomain looks for featured images it is trying to load
subdomain.example.com/wp-content/uploads/sites/{blog-id}/{dated_subdirectories}
Is there a way to - perhaps using htaccess - forward/redirect those requests to:
example.com/wp-content/uploads/{dated_subdirectories}
I have tried various ways including .htaccess redirect for images from old folder to new folder and I either get a 500 error or the WordPress nothing found page.
Try this rule in wp-content/uploads/.htaccess file:
RewriteEngine On
RewriteBase /wp-content/uploads/
RewriteRule ^sites/[^/]+/(.+)$ $1 [L,R=302,NC]
Just building a site using php. I would like to know how to create pages without having to make ".php" links for every page. For example I want to build the site to be as follows: www.mysite.com/products instead of www.mysite.com/products.php. (Further example www.mysite.com/products/headphones )
An example of what I am looking for is as follows: http://www.starbucks.ca/store-locator
Any idea how starbucks is doing this? It isn't making a separate folder and index for every page is it?
Thanks in advance!
Jason
You can use URL rewriting to do this. You can create a .htaccess file, place it in the root directory of your website with the following content (as an example):
RewriteEngine On
RewriteRule ^tutorial/([0-9]+)/$ index.php?tutorial=$1
RewriteRule ^page/store-locator/$ index.php?page=store-locator
RewriteRule ^$ index.php
These are some basic rules that tell the web server to rewrite a URL without .php to a URL that does have .php.
In the above example, when you are visiting example.com/tutorial/3/, it will actually visit example.com/index.php?tutorial=3 and then your index.php will display the contents. It's similar for the store-locator page.
I'm looking to 301 redirect an URL from a old version of a site no longer being used to a new URL that has been created in fresh Drupal installation.
Old URL: /198/our-software/
New URL: /services/software-development/
In the .htaccess located in the root directory of Drupal I have added the following:
redirect 301 /198/our-software/ http://www.domain.com/services/software-development
The redirect is working to some extent, it sends the user to a url like below with a query string appended to the end of it, which results in a 404 error:
http://www.domain.com/services/software-development?q=198/our-software/
I have tried placing the redirect at both the start and end of the .htaccess file both result in a 404 page not found error.
Do I need to use a more complex redirect to get around Drupals URL rewrite?
NOTE: I'm using the Pathauto module.
Rather than edit the .htaccess directly, just install the Path Redirect module which has that exact functionality built in.
Note that the Path Redirect module is only available for Drupal 6 (as of 2/22/12)
I got it working with using "RewriteRule" instead, AND (important!) removing the leading slash in the source URL, so in your case:
RewriteRule 198/our-software/ http://www.domain.com/services/software-development [R=301,L]