Mega list of redirects (.htaccess) - Printable Version +- NiftyHost Forums (Archive) (https://niftyhost.chary.us/support) +-- Forum: Technology (https://niftyhost.chary.us/support/forum-7.html) +--- Forum: Tutorials (https://niftyhost.chary.us/support/forum-10.html) +--- Thread: Mega list of redirects (.htaccess) (/thread-351.html) |
Mega list of redirects (.htaccess) - Mone - 07-04-2010 well lets start but before we do red this lil snippet notes on htaccess redirection
Quote:Always be sure to upload .htaccess files in ascii mode, sending it up as binary will break it (and usually make your server very, very unhappy.) ok now lets begin are 1st one is 301 sounds crazy but lets go at it for an single page Code: Redirect 301 /oldpage.html http://www.example.com/newpage.html now for an entire site you do this Code: Redirect 301 / http://www.example.com/ now to change the end of it Code: RedirectMatch 301 (.*)\.html$ http://www.example.com$1.php Quote:This example is perfect if you've decided to switch to .php from .html pages. It will look for any .html page and redirect it to .php (ie http://www.example.com/yourpage.html and redirect it to http://www.example.com/yourpage.php). Now, be careful with this, it does mean any html page. I did this on one of my sites and had totally forgotten I had an iframe with .html content on some pages... I didn't notice for weeks that it was broken :S. The most common meta redirect is Code: meta http-equiv="refresh" content="10; url=http://example.com/"> if i missed an feel free to say so RE: Mega list of redircts - RichardGv - 07-04-2010 1. Thanks. 2. .htaccess works under both Windows and *nix versions of Apache, as far as the server is configured correctly (depends on AccessFileName and (kind of) AllowOverride). http://httpd.apache.org/docs/trunk/howto/htaccess.html (It's nevertheless true that Windows don't hide files with names starting with dot, unlike *nix systems.) 3. There's something that you may want to pay attention, about the directive Redirect: Quote:Redirect DirectiveSo, for example, if somebody tries to access http://your-site.com/oldpage.html.old/testpage.html, and you have this rule in your .htaccess: Code: Redirect 301 /oldpage.html http://example.com/newpage.html 4. mod_rewrite provides a much more flexible solution that mod_alias for redirections, which you might be interested in: http://httpd.apache.org/docs/2.2/misc/rewriteguide.html 5. About the example of the removal of .html extension, you can use mod_rewrite to avoid the problem that accesses to existing files are redirected incorrectly: Code: RewriteCond %{REQUEST_FILENAME} !-f Code: RewriteCond %{REQUEST_FILENAME} !-f RE: Mega list of redircts - HiddenKnowledge - 07-06-2010 Ok, two things. Mone, check the spelling of your post (look at the topic...) And the code blocks are not working, please use quote blocks. |