View Full Version : .htaccess and 301 redirects
Sdashiki
Oct 26, 2009, 09:33 AM
I just had htaccess "turned on" at my free host (110mb.com)...
Because I switched from .html to .php for alot of my site and want anytime someone hits an old link to get them to the new link. There are links to various pages on my site all over the web and I cant change them all by request to webmasters...
So, Im trying 301 redirects:
Redirect 301 /index.html http://site
This .htaccess file is located in root/polaroid/ so when someone looks for:
http://site
they get
http://site
Yet this doesnt happen...you can freely navigate to the .html page without an redirection.
Did my host forget to turn .htaccess on (though their email said it was) or am I configuring this completely wrong?
ps: no i dont want EVERY .html page accessed to be turned into .php because I still have some .html pages within the site.
SrWebDeveloper
Oct 26, 2009, 10:59 AM
First test determine if they allow you to use .htaccess by simply using a few characters of garbage text in your .htaccess. If you get an Internal Server Error 500 or actually an error of any kind, your .htaccess is at least being processed. Then you start debugging command syntax in your .htaccess, i.e. for your situation you might want to try:
RewriteEngine on
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.html\ HTTP/
RewriteRule ^(([^/]+/)*)index\.html$ /index\.php [R=301,L]
If nothing happens, a proper .htaccess setup in Apache2's configuration files include:
Enabling mod_rewrite module
For your directory, make sure "AllowOverride All" and not set to "none"
Options FollowSymLinks
Here is an example of a typical virtual subhost setup in Apache2's virtual host file with .htaccess support enabled:
<VirtualHost *>
DocumentRoot /var/www/foobar
ServerName foobar.com
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
</VirtualHost>
Remember they have to restart Apache after making any changes to the configuration on their end.
Rarely, some webhosts choose a different filename instead of .htaccess for security reasons, so if all else fails ask them if you're using the right filename as a last resort - and remember, this is VERY rare. This is all I can think of to help ya.
-jim
Angelo95210
Oct 26, 2009, 11:13 AM
Here is a line of my .htaccess if it can help :
Redirect 301 /component/option,com_linx/Itemid,93/ /links.php
angelwatt
Oct 26, 2009, 11:53 AM
I believe you'll need,
Redirect 301 /polaroid/index.html http://option8.110mb.com/polaroid/index.php
as simply placing the .htaccess file into the polaroid folder doesn't make that the new root folder that it's accessing.
Also be sure to pay attention to SrWebDeveloper's advice for the rewrite engine. You'll be able to simplify how much you have to write for your redirects using that method rather than doing a Redirect line for each page. If you need help just keep asking.
Sdashiki
Oct 26, 2009, 01:08 PM
Yeaaaa, a little more research showed me that putting garbage (or anything of bad syntax) would give you a server error and not...nothing.
So when I tested garbage...nothing happened.
I dont think they gave me .htaccess yet...(its a lifetime upgrade $9) even though an email 2 days ago said I did because that wasnt the receipt email...it was specific to say:
«¤»¥«¤»§«
¯¯¯¯¯¯¯¯¯
You now have full access to:
1) .htaccess files support (in any directory)
2) .htpasswd files support (in any directory)
Regardless my new "updated" site took all my pages and removed the header/footer/side menus on both sides (3 column fixed layout) into "include ()" calls to simplify my updates. So only in a few cases will this truly change the syntax of the link from anything but .html>.php
Where it would change is because for all the subfolders within /polaroid/ i changed the original #1 page for that section to index.php. Example: /polaroid/104/104.1.html became /polaroid/104/index.php
But besides that, everything else is just .html>.php change.
vBulletin® v3.8.6, Copyright ©2000-2012, Jelsoft Enterprises Ltd.