[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

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


Closed Thread
 
LinkBack Thread Tools
Old 08-14-2008, 04:40 AM   #1 (permalink)
NamePros Regular
 
Rudy's Avatar
 
Join Date: Jul 2005
Location: United States
Posts: 588
613.72 NP$ (Donate)

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.

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, 05:25 AM   #2 (permalink)
Traveller
 
-NC-'s Avatar
 
Join Date: Mar 2007
Location: Yet another city
Posts: 1,392
614.57 NP$ (Donate)

-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of

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.
-NC- is offline  
Old 08-14-2008, 05:32 AM   #3 (permalink)
NamePros Regular
 
Rudy's Avatar
 
Join Date: Jul 2005
Location: United States
Posts: 588
613.72 NP$ (Donate)

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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 11:32 AM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85