These procedures. Htaccess you should know in web design
The command line. Htaccess file should begin as follows:
RewriteEngine On
RewriteBase /
The basic command line redirect 301
301 redirect command basically takes the following form in the file. Htaccess:
redirect 301 / old / old.htm http://www.vietprotocol.com/new.htm
Command line on transfer leave files old.htm notice in the old folder to the new location in http://www.vietprotocol.com/new.htm.
Note: To start, you should redirect the 301 pages on the same host, you should just move the old page relative to the root directory. You can do this by removing “http://www.vietprotocol.com/” which only add the relative path to the root.
Strongest point of the mass change the URL path is Apache’s mod_rewrite, especially when the domain name changes or folder
or large numbers of files. We learn next.
Move all to new domain
If you decide to change the domain name, the previous path from the external website, from search engines and even the absolute path on the old website will be changed and when you visit, the address will point you to the error page 404: page not found.
So if you change your domain name, do not lose valuable links and potential users from a search engine, redirect the old links to the new domain:
Options + FollowSymLinks
RewriteEngine on
RewriteRule (. *) Http://www.vietprotocol.com/ $ 1 [R = 301, L]
Please change www.vietprotocol.com with your new domain name.
Redirect the entire page in a folder to a new page
Let’s say you are no longer use directory “thuthuatseo” anymore and want to move all the pages in this folder to “seoblog.php”, add the following line to the file. Htaccess file located in the root directory:
RewriteRule ^ thuthuatseo (. *) $ / Seoblog.php [L, R = 301]
Moving the page to a new page
To visit the site page.php? Id = n (where n is the value of the variable) to a new static page new-page.html, you can do the following:
RewriteRule ^ page.php? Id = (. *) $ / New-page.htm [L, R = 301]
URL with www or non-www
Sometimes you come across the website using the “www” in the URL (for example http://truongchieu.byethost8.com), while the website does not use “www” as http://aevn.fr . Remember that “corresponds” to the Web service. You can choose your own. But can not choose both because it will cause duplicate content. The following are two examples, thoroughly guide you through the problem.
Where the use of www
Options + FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond% {HTTP_HOST}! ^ Www \. VietProtocol. \ Net $ [NC].
RewriteRule ^ (. *) $ Http://www.vietprotocol.com/ $ 1 [R = 301, L]
There is also a post can be applied to all host and domain, do not have to edit:
Options + FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond% {HTTP_HOST}! ^ Www \. [Az-] + \. [Az] {2,6} [NC]
RewriteCond% {HTTP_HOST} ([az-] + \. [Az] {2,6}) $ [NC]
RewriteRule ^ / (. *) $ Http://% 1 / $ 1 [R = 301, L]
Where not use www
Options + FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond% {HTTP_HOST}! ^ Aevn \. Fr $ [NC]
RewriteRule ^ (. *) $ Http://aevn.fr/ $ 1 [R = 301, L]
You can try again with the domain name for example on which I successfully applied properly cited.
Remove QUERY_STRING
Sometimes a website you can display two different url but (same content) for example seo seo-tools.php and-tools.php? V = mobile. Same as above, this will issue duplicate content on your website. So you can remove the following parameters:
RewriteCond% {THE_REQUEST} ^ GET \ /. * \;. * \ HTTP /
RewriteCond% {QUERY_STRING}! ^ $
RewriteRule. * Http://www.vietprotocol.com% {REQUEST_URI}? [R = 301, L]
Also if the QUERY_STRING variable is not assigned any value all the empty variable and the URL ends with “?”, Then you should get rid of them, for example, “index.php?”:
RewriteEngine On
RewriteBase /
RewriteCond% {QUERY_STRING}.
RewriteRule ^ index.php / index.php? [L]
Jump extensions. Php to. Html
The transfer. Php to. Html effective when you need to rewrite search engine friendly links (Friendly URL for SEO).
RewriteRule ^ (. *) \. Html $ $ 1.php [R = 301, L]
Move the underscore (_), hyphen (-)
Although Google accept that the use of the underscore “_” as separator character, but in fact the user is familiar with the dash “-“. The VietProtocol themselves supporters dash because it’s easier to look at. You can convert all “_” to “-“, as follows:
Options + FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule! \. (Html | php) $ – [S = 4]
RewriteRule ^ ([^ _] *) _ ([^ _] *) _ ([^ _] *) _ ([^ _] *) _ (. *) $ $ 1 – $ 2 – $ 3 – $ 4 – $ 5 [E = uscor: Yes]
RewriteRule ^ ([^ _] *) _ ([^ _] *) _ ([^ _] *) _ (. *) $ $ 1 – $ 2 – $ 3 – $ 4 [E = uscor: Yes]
RewriteRule ^ ([^ _] *) _ ([^ _] *) _ (. *) $ $ 1 – $ 2 – $ 3 [E = uscor: Yes]
RewriteRule ^ ([^ _] *) _ (. *) $ $ 1 – $ 2 [E = uscor: Yes]
RewriteCond% {ENV: uscor} ^ Yes $
RewriteRule (. *) Http://www.vietprotocol.com/ $ 1 [R = 301, L]
Redirect WordPress Feeds to Feedburner
In use Feedbuner article, you can use the plugin to manage RSS Feeds on WordPress Blog. Otherwise you can use the following htaccess code:
RewriteEngine On
RewriteBase /
RewriteCond% {REQUEST_URI} ^ / feed \. Gif $
RewriteRule. * – [L]
RewriteCond% {HTTP_USER_AGENT}! ^. * (FeedBurner | FeedValidator) [NC]
RewriteRule ^ feeds /?. * $ Http://feeds.vietprotocol.com/quangbaweb/ [L, R = 302]
RewriteCond% {REQUEST_FILENAME}!-F
RewriteCond% {REQUEST_FILENAME}!-D
RewriteRule. / Index.php [L]
For WordPress users, you can use the plug-in Permanent Link Redirection to redirect the page.
Protection of resources and bandwidth stealing
Sometimes the document, video or image that you load on your host used by others and posted on other websites will result in waste of bandwidth, you can limit the steal by only allowing the resources on accessible on the website allows the following (If not will return the / feed /):
RewriteEngine On
RewriteBase /
RewriteCond% {HTTP_REFERER}! ^ $
RewriteCond% {HTTP_REFERER}! ^ Http:// (www \.)? Vietprotocol.com /. * $ [NC]
RewriteRule \. (Gif | jpg | swf | flv | png) $ / feed / [R = 302, L]
301 redirect on the server applications (other than Apache)
IIS redirect
In the internet service administrator, right-click the selected files and folders that you want to apply to redirect;
Select the button “A redirection to a URL”;
Choose site Redirection;
Select next “The exact url đã nhập above” and “A permanent redirection for this resource”;
Select “Apply”.
ASP Redirec
<% @ Language = VBScript%>
<% Response.Status = “301 Moved Permanently” Response.AddHeader “Location”, “http://www.vietprotocol.com/”%>
JSP (Java) Redirect
<% Response.setStatus (301); response.setHeader (“Location”, “http://www.vietprotocol.com/”); response.setHeader (“Connection”, “close”);%>
CGI PERL Redirect
$ Q = new CGI;
redirect(“http://www.vietprotocol.com/”);”>print $ q-> redirect (“http://www.vietprotocol.com/”);
Ruby on Rails Redirect
def old_action
headers [“Status”] = “301 Moved Permanently”
redirect_to “http://www.vietprotocol.com/”