Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Server Operation

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 11th April 2010, 00:29
sfunk1x sfunk1x is offline
Member
 
Join Date: Jun 2009
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default 301 redirects, trailing slashes and folders that begin with an underscore

Hey all -

I'm running into an issue with an .htaccess file with some 301 redirects.

I'm running a server that has a site which has an .htaccess file redirecting several domain names to another single canonical name. Those redirects work great, until you try going to a particular subfolder of a site which starts with an underscore, for example:

oldsitedomainname.com/_admin

would be redirected to:

http://www.newsitedomainname.com/_admin

however, it's actually being re-written like this:

http://www.newsitedomainname.com_admin

which doesn't work for obvious reasons.

I added the following code snippet from a 301 howto in order to add a trialing slash to URLs, which seems to work great, but that hasn't solved the problem:

rewriteCond $1 !/$
rewriteCond %{REQUEST_FILENAME}/ -d
rewriteRule (.+) http://www.newsitedomainname.com/$1/ [R=301,L]

Anyone have any suggestions? Thanks in advance!
Reply With Quote
Sponsored Links
  #2  
Old 13th April 2010, 20:14
sfunk1x sfunk1x is offline
Member
 
Join Date: Jun 2009
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Wow, so no one uses 301 redirects? Is there another method I could use to perform this same function?

Also, I'm running into a problem of the redirects only redirecting non-www addresses. Anytime someone prepends a www to the address, it won't get re-written.
Reply With Quote
  #3  
Old 13th April 2010, 22:35
drieschel drieschel is offline
Junior Member
 
Join Date: Apr 2010
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi sfunk1x,

try this:

RewriteCond %{HTTP_HOST} !^www\.newsitedomainname\.com [NC]
RewriteCond %{HTTP_HOST} !^$

RewriteRule (.*) http://www.newsitedomainname.com/$1 [R=301,L]

Maybe it will work.

Greetz
drieschel
__________________
My company: speicher::werk

My blog: immanuel-klinkenberg.de
Reply With Quote
  #4  
Old 14th April 2010, 21:23
sfunk1x sfunk1x is offline
Member
 
Join Date: Jun 2009
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
 
Default

Wow, that took care of it. Thank you very much!
Reply With Quote
Reply

Bookmarks

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 08:30.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.