NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page [resolved] .htaccess Problems

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 08-14-2008, 05:40 AM THREAD STARTER               #1 (permalink)
NamePros Regular
 
Rudy's Avatar
Join Date: Jul 2005
Location: United States
Posts: 586
Rudy is just really niceRudy is just really niceRudy is just really niceRudy is just really nice
 


Save a Life

.htaccess Problems


Hey guys,
I've just added a .htaccess file to my website for the first time a couple days ago. I'm doing quite a bit of work and research on SEO for the first time in a long time (ever?) and am learning quite a bit. Anyway, one thing I wanted to do was redirect requests coming for http://domain.com TO http://www.mydomain.com.

It is working. To an extent.

Since I have uploaded the .htaccess file, every time I go to http://domain.com/directory, I am taken to my 404 Error Page. But, of course, when I go to http://www.domain.com/directory, I am taken to where I want to go.

My culprit lies somewhere in here, at the top of my .htaccess file. I copied pretty much all of this code from some tutorials, etc... I've read on the internet. Here's what I've got:

<Files .htaccess>
order allow,deny
deny from all
</Files>
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^mydomain.com [nc]
rewriterule ^(.*)$ http://www.mydomain.com/$1 [r=301,nc]
ErrorDocument 404 /error404.php

By the way, do I need to run "RewriteEngine on" everytime I want to "rewrite" something? For example, I read a tutorial that gave some code to prevent a lot of the well known "black" bots from gaining access to my website. I decided to go ahead and include that. So underneath the last line you see here, I have "RewriteEngine on" again, and a LOT of rewritecond, checking to see if the bot should have permission or not.
????: NamePros.com http://www.namepros.com/programming/503619-resolved-htaccess-problems.html

Here's the first and last line of that:
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} ^BlackWidow [OR]
etc... etc... etc...
RewriteRule ^.* - [F,L]
Rudy is offline  
Old 08-14-2008, 06:25 AM   #2 (permalink)
Traveller
 
-NC-'s Avatar
Join Date: Mar 2007
Location: Yet another city
Posts: 1,419
-NC- has a brilliant future-NC- has a brilliant future-NC- has a brilliant future-NC- has a brilliant future-NC- has a brilliant future-NC- has a brilliant future-NC- has a brilliant future-NC- has a brilliant future-NC- has a brilliant future-NC- has a brilliant future-NC- has a brilliant future
 


Animal Cruelty Animal Rescue Ethan Allen Fund Protect Our Planet
what happens if you include the URI and L option here:

change:
rewriterule ^(.*)$ http://www.mydomain.com/$1 [r=301,nc]

to:
RewriteRule ^.*$ http://www.domain.com%{REQUEST_URI} [R=301,L]

and AFAIK, you only need to put RewriteEngine on once, before the rewrites.
__________________
NameCooler.com
-NC- is offline  
Old 08-14-2008, 06:32 AM THREAD STARTER               #3 (permalink)
NamePros Regular
 
Rudy's Avatar
Join Date: Jul 2005
Location: United States
Posts: 586
Rudy is just really niceRudy is just really niceRudy is just really niceRudy is just really nice
 


Save a Life
I think that seems to do the trick. I've tested it on a couple different directories, and it's working just fine. Thanks for the help!

I think part of it was also that one of the directories is password protected. Even now, I'm still getting the same problem when I try to go to that password protected directory. But for regular dirs, it works great - and that's what matters. I don't want to make that password protected directory easy to get in to anyway, obviously.
Rudy is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Liquid Web Smart Servers  
All times are GMT -7. The time now is 02:30 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger