URL redirection, also known as URL forwarding.
Sometime the page URL can be change and it is already crawled or someone had bookmarked it. When that user comes it returns 404 at that time. To avoid 404 or any other URL, just rewrite URL rule and redirect it to new address.
There are many other applications for mod_rewrite that you can know about at apache.org. Please reference their website for other possible rewrite rules.
http://mywebsite.com/directory1 to http://mywebsite.com/directory2
Create .htaccess file and copy/paste below code:
How it works:
Let us know if you have any query and read our PHP/WordPress articles.
Enjoy! :)
Sometime the page URL can be change and it is already crawled or someone had bookmarked it. When that user comes it returns 404 at that time. To avoid 404 or any other URL, just rewrite URL rule and redirect it to new address.
There are many other applications for mod_rewrite that you can know about at apache.org. Please reference their website for other possible rewrite rules.
URL redirection
Example:http://mywebsite.com/directory1 to http://mywebsite.com/directory2
Create .htaccess file and copy/paste below code:
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^directory1.*$ http://mywebsite.com/directory2/ [R=301,L]
How it works:
- Options +FollowSymLinks is an Apache directive, prerequisite for mod_rewrite.
- RewriteEngine On enables mod_rewrite.
- RewriteRule defines a particular rule.
- The first string of characters after RewriteRule defines what the original URL looks like. There’s a more detailed explanation of the special characters at the end of this article.
- The second string after RewriteRule defines the new URL. This is in relation to the document root (html) directory. / means the html directory itself, and subfolders can also be specified.
- $1 at the end matches the part in parentheses () from the first string. Basically, this makes sure that sub-pages get redirected to the same sub-page and not the main page. Leave it out to redirect to the main page. (It is left out in the first two examples for this reason. If you don’t have the same content in the new directory that you had in the old directory, leave this out.)
- [R=301,L] – this performs a 301 redirect and also stops any later rewrite rules from affecting this URL (a good idea to add after the last rule). It’s on the same line as RewriteRule, at the end.
Let us know if you have any query and read our PHP/WordPress articles.
Enjoy! :)
Do not use a humidifier in your home if you suffer from allergies. Humidifiers are excellent for people who have a cold, but for allergy sufferers, they can worsen symptoms. Dust mites will thrive in moist air, and the wet air will cause mold to grow inside your home.satta king play bazaar
ReplyDelete