- This topic is empty.
-
AuthorPosts
-
October 24, 2011 at 3:32 am #34878lilyMember
I want to do 4 things to my website,
1. Redirect html to php
2. Redirect newyorkbydesign.com to http://www.newyorkbydesign.com
3. Have clean urls, such as, http://www.newyorkbydesign.com/portfolio/ instead of http://www.newyorkbydesign.com/portfolio.php, for all my webpages
4. Is there a way to hide, limit access, and/or limit viewing, to subfolders, such as script folders, note or image folders, etc.?This is what I have so far, but I know I’m incorrect. I’m new at this end of webdesign, could someone help fix me up? Thank so much for any help.
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^newyorkbydesign.com
RewriteRule (.*) http://www.newyorkbydesign.com/$1 [R=301,L]
RewriteRule ^(.+).html$ http://www.newyorkbydesign.com/$1.php [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.phpOctober 24, 2011 at 1:13 pm #89540standuncanMemberAs far as #1 goes, do you mean rewrite the extension just so it shows .html instead of .php, or actually redirect about.php to a new separate about.html document?
#2 http://perishablepress.com/press/2006/01/10/stupid-htaccess-tricks/#red2
#3 ?
#4 http://perishablepress.com/press/2006/01/10/stupid-htaccess-tricks/#sec3
October 24, 2011 at 5:21 pm #89565lilyMemberSorry I’m terrible at the explanation.
In my site, I started out with,
for example the page; newyorkbydesign.com/about.htmlThen changed to http://www.newyorkbydesign.com/about/.php
In the end want to show http://www.newyorkbydesign.com/about/
in the address barRedirecting each page to the www. address, redirecting the html’s to the php’s instead, and with the extension not showing in the end.
I hope that explains it better, it’s a real site, so you could actually see the pages and where I’m at with the coding and htaccess. I know it needs help, I don’t have this down yet.
Thanks so much for the help!
October 24, 2011 at 5:30 pm #89566lilyMemberSo StanDuncan,
I’ve got the pages to redirect from the non-www to the www, but I don’t have the rest of the coding right I’m sure. Is it because I have the order of the RewriteCond and RewriteRule messed up? Or am I off completely with the rest after the first RewriteRule above in my fist post?
Thanks
October 24, 2011 at 5:52 pm #89568lilyMemberActually I think I have the rediect from non-www to www and the redirect from html to php right. I tried it and it seems to be working. I don’t have the last part though, cleaning up the url to leave out the extension.
I typed in the address bar
newyorkbydesign.com/about.html and came out with,
http://www.newyorkbydesign.com/about.php
now if I could just get it to show without the pesky extension, that would be great!
Thanks
October 24, 2011 at 5:55 pm #89569lilyMemberStanDuncan, I’m checking out the links you put in your post for me, I figured I wouldn’t attempt the fourth request until I understand the others fully, first.
October 24, 2011 at 8:14 pm #89572standuncanMemberI’m not an .htaccess expert by any means, but if I understand what you’re are wanting to do correctly, I would be using 301 redirects from your old .html pages, to your new .php pages, this will be better for SEO as well.
Than you will use the mod_rewrite command to remove your php extensions, as long as your host allows this, it’s an apache server and mod_rewrite is enabled, which it sounds like it is already.
Here is one .htaccess example:
Options +FollowSymlinks
RewriteEngine on
# If requested URL-path plus ".php" exists as a file
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
# Rewrite to append ".php" to extensionless URL-path
RewriteRule ^(([^/]+/)*[^.]+)$ /$1.php [L]
redirect 301 /index.html http://www.domain.com/index.php
redirect 301 /about.html http://www.domain.com/about.php
However, after you get the extensions removed remember to go back into all your files and remove the .php from any links, so your navigation might appear as
nav.php
Also if that one mod_rewrite rules does not work, here are two more to try. Some times they work on sites I work on, sometimes they don’t depending on the host:
October 24, 2011 at 8:38 pm #89573lilyMemberIt works up until the extension still showing, so I’m going to check out the other link you show above. Could it have something to do with the hosting site, GoDaddy?
October 24, 2011 at 8:40 pm #89574lilyMemberYour htaccess code is much neater and better than mine, by the way. Mine is very rudimentary!
October 24, 2011 at 8:52 pm #89575lilyMemberWell, I don’t know not one of them worked. I read those posts, I agree with you it does seem simple enough, by why doesn’t any code to get rid of the extensions work?
October 24, 2011 at 8:57 pm #89576lilyMemberIs it a symlink thing? Do I have to put everything into subdirectories. Wouldn’t a subdirectories add unnecessary re-routing, like over the river and through the woods to get to a file? I would think (though I know very little!), but I do not know.
Thanks for helping me, still!
October 25, 2011 at 1:16 am #89585standuncanMemberIf none of those versions worked, I can’t help beyond that. On Godaddy, I have to deal with them often, half the time those work, half the time they don’t. Only pattern I have noticed is if the site is in the root of the hosting plan or not, I think that is why. However if the .htaccess is in the root of web directory, it shouldn’t matter. Sorry I can’t help more..
October 25, 2011 at 11:04 am #89611lilyMemberOh, well thanks so much for trying, I appreciate the time and effort.
My .htaccess file is in the root directory of my site files. I was wondering if you’ve noticed this also with, your files on the server, if I look through the Godaddy hosting FTP I can see another folder in the remote directory; /stats/. In that directory is a blank .htaccess file that I can download, I can update it, but the Godaddy hosting transfer doesn’t allow it to be uploaded. That /stats/ folder also doesn’t show in the ftp file management section at all, nor does it show when I up/download from Dreamweaver.
One last question, albeit it ay be a dumb one, how do I know if my site is in the root of the hosting plan or not?
October 25, 2011 at 11:23 am #89617standuncanMemberJust ask your hosting company where your root folder is. Usually it is called public_html, www, web, root, etc.
As for as Godaddy goes, I can’t stand them. They try to limit and block so many options it seems like. Yes I have noticed that folder, I just leave it alone usually.
-
AuthorPosts
- The forum ‘Other’ is closed to new topics and replies.