Page 1 of 3 123 LastLast
Results 1 to 10 of 26

Thread: htaccess RewriteCond not properly working

  1. #1
    Junior Member
    Join Date
    Jan 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default htaccess RewriteCond not properly working

    I could have sworn I posted this already, but looking back the thread is just not there at all.

    I'm running Hotaru on a regular site (not on a subdomain, etc.), but the RewriteCond doesn't seem to be working.

    Example:

    www.mysite.com -- Works fine.
    mysite.com -- 404 error!

    My htaccess file reads as follows:

    Options +Indexes +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.php\ HTTP/
    RewriteCond %{HTTP_HOST} !^www\.
    RewriteRule ^\/?(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

    Any ideas what's going on here? (Because I don't!)

    Cheers.

  2. #2
    Admin & Design JonH's Avatar
    Join Date
    Jun 2009
    Location
    New Braunfels, Texas
    Posts
    248
    Thanks
    57
    Thanked 49 Times in 30 Posts

    Default

    Hi Alex, yeah I think your www.mysite.com example must have triggered the spam filter.

    I believe that's correct for your htaccess , the same as it is by default.
    Not sure here's a few things you can try...
    What version of Hotaru?
    In your hotaru_settings.php for your site path did you include the www?
    Also try renaming your htaccess back to htaccess_default set friendly urls back to false to rule out if it's an htaccess problem.

  3. #3
    Former lead dev Nick's Avatar
    Join Date
    Jun 2009
    Location
    Kakamigahara, Japan
    Posts
    2,858
    Blog Entries
    88
    Thanks
    482
    Thanked 806 Times in 526 Posts

    Default

    I had a few problems myself setting up my own site. It was a combination of BASEURL, htaccess and cookie problems. Here's what I did to resolve it:

    1. Change BASEURL to http://yoursite.com in hotaru_settings.php (i.e. NOT www)
    2. Change:

    Code:
    ## Remove these two lines if you have a sub-domain like  http://bookmarking.myhotarusite.com  or http://localhost
    ## Keep if your site url looks like http://www.myhotarusite.com
    RewriteCond %{HTTP_HOST} !^www\.
    RewriteRule ^\/?(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
    ##### Re-directing End #####
    to:
    Code:
    RewriteCond %{HTTP_HOST} ^www\.yoursite\.com [NC]
    RewriteRule ^(.*)$ http://yoursite.com/$1 [R=301,L]
    I'm not too bright when it comes to htaccess, but I found that on Google and it worked, redirecting everything from www to a plain non-www format. I did that because I was having problems with cookies "sticking" across www and non-www formats, so made it easier by forcing everything to non-www (which seems to be the trend lately anyway).

    3. Wait a couple of days for Hotaru 1.0.5 which has an updated UserAuth file to get the cookies working okay.

    Hopefully as more and more people set up Hotaru, it will become clearer what works and what doesn't.

  4. #4
    Junior Member
    Join Date
    Jan 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Well, I really appreciate the replies guys, but the result was the opposite! Haha. Having applied Nick's advice, mysite.com was being recognized, but not with the www.

    In the end, I just went with the friendly URLs turned off, and users will have to log-in twice in the worst case scenario (once for the site with www, once without), but the cookies seem to be sticking now.

    Thanks for the quick replies!

    Cheers.

  5. #5
    Senior Member
    Join Date
    Sep 2009
    Location
    WorldWid3
    Posts
    272
    Thanks
    34
    Thanked 38 Times in 26 Posts

    Default

    Just noticed that even when friendly urls are turned on the following don't display properly

    /index.php?pg=2
    /index.php?page=comments&pg=2
    /index.php?category=news&pg=2
    /index.php?tag=microsoft&pg=2
    /index.php?page=latest&pg=2

    Thanks.

  6. #6
    Former lead dev Nick's Avatar
    Join Date
    Jun 2009
    Location
    Kakamigahara, Japan
    Posts
    2,858
    Blog Entries
    88
    Thanks
    482
    Thanked 806 Times in 526 Posts

    Default

    Yeah, sorry, friendly urls in pagination was really buggy so I dropped it.

  7. #7
    Senior Member
    Join Date
    Sep 2009
    Location
    WorldWid3
    Posts
    272
    Thanks
    34
    Thanked 38 Times in 26 Posts

    Default

    I'm also having issues with the .htaccess redirect condition, I would like for all users who use the www. format to be redirected to the non www format

    I've defined my site/baseurl as mysite.com/ on the hotaru_settings.php file and have the following as the re-write condition in .htaccess file, which actually redirects all the www format to non www format, however now im having issues with my subdomains (blog.mysite.com) coming up as page not found

    RewriteCond %{HTTP_HOST} !^www\.
    RewriteRule ^\/?(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

    I found this google.

    ## Redirect if NOT example.com (exactly) to example.com
    RewriteCond %{HTTP_HOST} .
    RewriteCond %{HTTP_HOST} !^mysite\.com
    RewriteRule (.*) http://mysite.com/$1 [R=301,L]

    Any help here would be greatly appreciated!

  8. #8
    Former lead dev Nick's Avatar
    Join Date
    Jun 2009
    Location
    Kakamigahara, Japan
    Posts
    2,858
    Blog Entries
    88
    Thanks
    482
    Thanked 806 Times in 526 Posts

    Default

    Did the rules I used in my .htaccess file not work for you? (See post #3 above)

  9. #9
    Senior Member
    Join Date
    Sep 2009
    Location
    WorldWid3
    Posts
    272
    Thanks
    34
    Thanked 38 Times in 26 Posts

    Default

    Hey Nick, after implementing you recommendations im still unable to get www.mysite.com to redirect to mysite.com. but some how i have managed to get this working using the following:

    'BASEURL', "http://mysite.com/"

    My .htaccess file looks as following :

    ##### Re-directing Begin #####
    Options +Indexes +FollowSymlinks
    RewriteEngine on
    ## If Hotaru is installed in a subfolder, change the below line to RewriteBase /name-of-subfolder
    RewriteBase /
    ## If installed in a subfolder you may need to add ## to the beginning of the next line
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.php\ HTTP/

    ## Remove these two lines if you have a sub-domain like http://bookmarking.myhotarusite.com or http://localhost
    ## Keep if your site url looks like http://www.myhotarusite.com
    RewriteCond %{HTTP_HOST} ^www\.mysite\.com [NC]
    RewriteRule ^(.*)$ http://mysite.com/$1 [R=301,L]

    RewriteCond %{HTTP_HOST} .
    RewriteCond %{HTTP_HOST} !^mysite\.com
    RewriteRule (.*) http://mysite.com/$1 [R=301,L]
    ##### Re-directing End #####

    But now im having a whole other issue with some sub domains not redirecting.
    e.i analytics.mysite.com comes up an error 404.

  10. #10
    Former lead dev Nick's Avatar
    Join Date
    Jun 2009
    Location
    Kakamigahara, Japan
    Posts
    2,858
    Blog Entries
    88
    Thanks
    482
    Thanked 806 Times in 526 Posts

    Default

    Quote Originally Posted by angolanmade View Post
    im still unable to get www.mysite.com to redirect to mysite.com. but some how i have managed to get this working
    Sorry, I don't understand. You say you can't get it working, but can get it working.

    You need to be very clear about what you want your htaccess file to do. You must choose either www or non-www. You can't have both because Hotaru cookies won't work with both. [Edit: sorry, I just noticed you were very specific about your goals in post #7]

    My .htaccess file successfully redirects www.example.com to example.com. It allows subdomain.example.com. It looks like this:
    Code:
    #############################
    ##### EDIT THIS SECTION #####
    #############################
    
    Options +Indexes +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    RewriteCond %{HTTP_HOST} ^www\.japansoc\.com [NC]
    RewriteRule ^(.*)$ http://japansoc.com/$1 [R=301,L]
    
    ################################################
    ##### DON'T EDIT ANYTHING BELOW THIS POINT #####
    ################################################
    I have not seen a working .htaccess file for only www. links. If anyone has one, please share.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Working with Subversion
    By Nick in forum How-To and Troubleshooting
    Replies: 13
    Last Post: 04-24-2012, 05:09 AM
  2. .htaccess RewriteCond for www not working.
    By Alex in forum How-To and Troubleshooting
    Replies: 0
    Last Post: 01-29-2010, 02:10 PM
  3. WampServer and .htaccess
    By rushnp774 in forum How-To and Troubleshooting
    Replies: 2
    Last Post: 11-29-2009, 05:46 PM
  4. [Docs] Example .htaccess Files
    By Nick in forum Getting Started with Hotaru CMS
    Replies: 0
    Last Post: 11-29-2009, 06:35 AM
  5. [Docs] Working with Plugin Hooks
    By Nick in forum Developing Plugins
    Replies: 2
    Last Post: 11-23-2009, 08:48 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •