Changes

Jump to navigation Jump to search

Htaccess: Redirect

18 bytes removed, 19:43, 5 April 2011
Punctuation and grammatical changes; some clarification.
'''Redirect'''
The htaccess command Redirect is very powerful you . You can redirect files or complete folders. Why would you want to do this a ? A typical example would be that you have changed the structure of your site but wish want to have old links (saved by a user) to be redirected to your new page location , or even a new page name.
== Redirect format ==
The redirect command must be on a single line with each element , separated by a space it . It has the following format:
:'''Redirect old_path new_path'''
=== Folder Redirect ===
Suppose that all you have done is renamed to rename a folder (and even possibly moved it to another location) ; however all the files still have their original names redirecting . Redirecting a folder is similar to the above ; for example:
'''Redirect /olddirectory <nowiki>http://yoursite.com/newdirectory</nowiki>'''
</ol>
'''''[[#top | Top]]'''''
== Directory example 1 ==
Using our '''errors folder''' make a copy of it and rename it to '''moved'''.
# You will be redirected to the folder '''<nowiki>http://localhost/moved/</nowiki>'''
'''''[[#top | Top]]'''''
== 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.
'''Testing'''
# You will be redirected to the file '''<nowiki>http://localhost/moved/not_found.html</nowiki>'''
Well , you get the idea experiment . Experiment with files ; it is similar to the folder example.
'''''[[#top | Top]]'''''
== Practical Example ==
I was faced with this very problem . UniCenter has been around for nearly two years and started to become unmanageable , hence the move over to the Wiki. Many web sites link to various pages on UniCenter , so to avoid the frustration of not finding an article; , users are redirected to the appropriate page on the Wiki.
Below is a small extract from my .htaccess file , where you will see I am using page redirection:
<pre>
</pre>
'''''Tip'':''' I first publish the Wiki pages, . Then I use a browser to view a page and copy the link into .htaccess. Similar The process is similar to obtain the redirected page.
=== Errors ===
The server encountered an internal error or misconfiguration and was unable to complete your request.
</pre>
 Hence Remember to always make small changes to .htaccess and then test, . This makes it easier to isolate and resolve any problems.
'''''[[#top | Top]]'''''
----

Navigation menu