Webmaster Forum


Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Coding Forum Problems with your code? Let's hear about it.

Bidding Directory   ClickBooth Network   V7N Directory

Reply
 
LinkBack Thread Tools Display Modes
Old 02-25-2006, 10:46 AM   #1 (permalink)
Inactive
 
Join Date: 02-18-06
Posts: 13
iTrader: 0 / 0%
Latest Blog:
None

Matthew Doucette is liked by many
.htaccess redirection problem; URL without ending slash 404s

Check this out:

http://xona.com/domainhacks/ works
http://www.xona.com/domainhacks/ works (and forwards to above URL)

However, remove the ending slash:
http://xona.com/domainhacks works
http://www.xona.com/domainhacks 404s!!!!!!!!!!!!!

Why? Here are the full .htaccess files, as I left everything in as experience has told me to never make assumptions:

xona.com root dir:
(This rewrite is supposed to change "www.xona.com" to "xona.com" everywhere.)
Code:
ErrorDocument 400 http://xona.com/error/400.html ErrorDocument 401 http://xona.com/error/401.html ErrorDocument 403 http://xona.com/error/403.html ErrorDocument 404 http://xona.com/error/404.html ErrorDocument 500 http://xona.com/error/500.html Options +Includes Options -Indexes XBitHack On RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} !^xona\.com [NC] RewriteRule ^(.*) http://xona.com/$1 [R=301]
--- I believe the above .htaccess to be perfect. I believe the problem is in the following .htaccess file below. I may be wrong. ---

xona.com/domainhacks dir:
(This rewrite is supposed to change "www.xona.com/domainhacks" to "xona.com/domainhacks" everywhere. The reason the root .htaccess file listed above does not handle this, is because this .htaccess file overrides it simply by existing.)
Code:
RewriteEngine On RewriteCond %{HTTP_HOST} !^xona\.com [NC] RewriteRule ^(.*)$ http://xona.com/domainhacks/$1 [R=301] RewriteRule ^search(.*)$ s.cgi$1 [NC] RewriteRule ^suggestions(.*)$ suggest$1 [R=301]
(I hate asking for help with this sort of thing, as I usually figure it out myself shortly afterwards. But so far I am stuck so it can't hurt.)
Matthew Doucette is offline  
Add Post to del.icio.us
Reply With Quote
Sponsored Links
SEO Hosting by HostGator  Advertise Here  Buy Blog Links
Old 02-25-2006, 02:25 PM   #2 (permalink)
Inactive
 
veridicus's Avatar
 
Join Date: 01-18-06
Posts: 139
iTrader: 0 / 0%
veridicus is just really niceveridicus is just really niceveridicus is just really niceveridicus is just really niceveridicus is just really niceveridicus is just really niceveridicus is just really niceveridicus is just really niceveridicus is just really niceveridicus is just really niceveridicus is just really nice
Couple of questions

A couple of questions/suggestions:

Try setting your default doc for the subdirectory to your default doc (index.htm, index.php, etc.).

You realize your htaccess is set to only redirect URLs containing the /, right? The line stating 301 is expecting a /.

Your root htaccess can do all of the redirects. Unless you really need to do something unique in a subdirectory I suggest doing everything in the root.

Why send everything back to the non-www URLs?
veridicus is offline  
Add Post to del.icio.us
Reply With Quote
Old 02-25-2006, 03:41 PM   #3 (permalink)
Inactive
 
Join Date: 02-18-06
Posts: 13
iTrader: 0 / 0%
Latest Blog:
None

Matthew Doucette is liked by many
veridicus, thanks for the reply.

Quote:
Try setting your default doc for the subdirectory to your default doc (index.htm, index.php, etc.).
Do you mean to have it forward to http://xona.com/domainhacks/index.html ? If so, the reason I do not do this is to have the URL very clean, so it shows off just two things: 1) "xona.com", which is also the name of the site, "Xona.com", not "Xona", and 2) "domainhacks" which is the name of the content/utility. This is purely a personal choice.

Quote:
You realize your htaccess is set to only redirect URLs containing the /, right? The line stating 301 is expecting a /.
I did not realize this. I thought it was redirecting anything that does not begin with "xona.com" (after the "http://") To be sure you and I are on the same page, are these the .htaccess lines ou are referring to (quoted below)?

Code:
RewriteCond %{HTTP_HOST} !^xona\.com [NC] RewriteRule ^(.*)$ http://xona.com/domainhacks/$1 [R=301]
Stilil on the same topic, refering the the quoted .htaccess code above, and recalling that this is the .htaccess file in the "domainhacks" folder... I thought this rules says: "If the URL does not start with "xona.com", then make the URL equal "http://xona.com/domainhacks/$1" where "$1" is everything after "domainhacks/" in the original URL." Please, if you can, clarify this for me!


Quote:
Your root htaccess can do all of the redirects. Unless you really need to do something unique in a subdirectory I suggest doing everything in the root.

Why send everything back to the non-www URLs?
This is exactly what I want to do! But I need a .htaccess in the "domainhacks" folder for other reasons, and as soon as I put a .htaccess file in the "domainhacks" folder, it cancels out the "www to non-www" redirect performed by the root .htaccess file. Is there a way to stop this cancellation from happening, or is it just standard protocol?

Thanks so much.
Matthew Doucette is offline  
Add Post to del.icio.us
Reply With Quote
Old 03-15-2006, 04:41 PM   #4 (permalink)
Inactive
 
Join Date: 02-18-06
Posts: 13
iTrader: 0 / 0%
Latest Blog:
None

Matthew Doucette is liked by many
Richard at doriat.com came up with a fix instantly. I hope it is ok to post this here:

http://www.doriat.com/viewtopic.php?p=1217

This was the fix Richard suggested, which works:

Try this line:
Code:
RewriteRule .* http://xona.com%{REQUEST_URI} [R=301,L]
instead of this line
Code:
RewriteRule ^(.*)$ http://xona.com/domainhacks/$1 [R=301]
If you wish, please comment on this. I would like to learn more about .htaccess coding.

I can see that Richard's fix works in all sub-folders, due to the access to the REQUEST_URI variable. Perhaps this means that I should put this line ONLY ONCE in the root .htaccess file, instead if in every sub-folder .htaccess file, and have it be inherited.
Matthew Doucette is offline  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum

Reply



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

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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help with .htaccess file (www. redirection) projectwealth Domain Name Forum 4 01-09-2008 06:32 AM
Please tell me how to make 301 redirection of these links in this .htaccess file? antispyware Coding Forum 1 07-10-2007 02:00 PM
cPanel Redirection = 301 redirection? sixty6 Web Hosting Forum 0 08-09-2006 08:07 PM
.htaccess redirect problem..! Immo Coding Forum 16 08-03-2006 04:02 AM
Redirection Problem! webexpertz SEO Forum 5 08-18-2005 12:24 AM


Sponsor Links
Get exposure! Get exposure! Find Scripts Web Hosting Directory Get exposure! SEO Blog


All times are GMT -7. The time now is 04:43 AM.
© Copyright 2008 V7 Inc