487
edits
(Punctuation and grammatical changes; some clarification.) |
(Punctuation and grammatical changes; some clarification.) |
||
Line 20: | Line 20: | ||
'''Redirect''' | '''Redirect''' | ||
The htaccess command | The Redirect .htaccess command is very powerful. You can redirect files or complete folders. Why would you want to do this? A typical example would be that you have changed the structure of your site but want to have old links (saved by a user) still function and be redirected to your new page location, or even a new page name. | ||
== Redirect format == | == Redirect format == | ||
The redirect command must be on a single line with each element | The redirect command must be on a single line with each element separated by a space. It has the following format: | ||
:'''Redirect old_path new_path''' | :'''Redirect old_path new_path''' | ||
=== File Redirect format === | === File Redirect format === | ||
Let's look at this in a little more detail using this example: | |||
'''Redirect /olddirectory/oldfile.html <nowiki>http://yoursite.com/newdirectory/newfile.html</nowiki>''' | '''Redirect /olddirectory/oldfile.html <nowiki>http://yoursite.com/newdirectory/newfile.html</nowiki>''' | ||
Line 37: | Line 37: | ||
* This is the path to the old file you want redirected | * This is the path to the old file you want redirected | ||
* It is stated in a relative file format | * It is stated in a relative file format | ||
* | * Followed again by a space | ||
<li> '''<nowiki>http://yoursite.com/newdirectory/newfile.html</nowiki>''' | <li> '''<nowiki>http://yoursite.com/newdirectory/newfile.html</nowiki>''' | ||
* This is the full (URL) path of the location you want the request redirected to | * This is the full (URL) path of the location you want the request redirected to | ||
</ol> | </ol> | ||
You would place a Redirect command in the root htaccess file for each file you want to redirect. | You would place a Redirect command in the root .htaccess file for each file you want to redirect. | ||
=== Folder Redirect === | === Folder Redirect === | ||
Line 54: | Line 54: | ||
* This is the path to the old directory you want redirected | * This is the path to the old directory you want redirected | ||
* It is stated in a relative file format | * It is stated in a relative file format | ||
* | * Followed again by a space | ||
<li> '''<nowiki>http://yoursite.com/newdirectory</nowiki>''' | <li> '''<nowiki>http://yoursite.com/newdirectory</nowiki>''' | ||
* This is the full (URL) path of the location you want the request redirected to | * This is the full (URL) path of the location you want the request redirected to | ||
Line 60: | Line 60: | ||
== Directory example 1 == | == Directory example 1 == | ||
Using our '''errors | Using our '''errors''' folder, make a copy of it and rename it to '''moved'''. | ||
{| | {| | ||
Line 80: | Line 80: | ||
Deny from all | Deny from all | ||
Allow from 127.0.0.1 | Allow from 127.0.0.1 | ||
Allow from ::1 | |||
# To allow execution of cgi scripts in this directory uncomment next two lines. | # To allow execution of cgi scripts in this directory uncomment next two lines. | ||
Line 100: | Line 101: | ||
'''Testing''' | '''Testing''' | ||
# Run the server using | # Run the server using Start.exe | ||
# In the browser address bar type '''<nowiki>http:/localhost/old</nowiki>''' | # In the browser address bar, type '''<nowiki>http:/localhost/old</nowiki>''' | ||
# You will be redirected to the folder '''<nowiki>http://localhost/moved/</nowiki>''' | # You will be redirected to the folder '''<nowiki>http://localhost/moved/</nowiki>''' | ||
== Directory example 2 == | == Directory example 2 == | ||
Open the file '''not_found.html''' contained in folder that was moved and add some more text to distinguish it from the original. | Open the file '''not_found.html''' contained in the folder that was moved and add some more text to distinguish it from the original. | ||
'''Testing''' | '''Testing''' | ||
Line 131: | Line 132: | ||
</pre> | </pre> | ||
'''''Tip'':''' I first | '''''Tip'':''' I first published the Wiki pages. Then I used a browser to view a page and copy the link into .htaccess. The process is similar to obtaining the redirected page. | ||
=== Errors === | === Errors === | ||
Line 143: | Line 144: | ||
---- | ---- | ||
[[Category: Support]] | [[Category: Support]] | ||
[[Category: Troubleshooting ]] | [[Category: Troubleshooting ]] | ||
[[Category: Application]] | [[Category: Application]] | ||
[[Category: Development]] | [[Category: Development]] |