Results 1 to 7 of 7
  1. #1

    Having trouble with htaccess redirect

    I am not a web designer. I am a networking person and I am trying to set up a server to run ownCloud and AjaXplorer on CentOS. Everything is working fine, except I can't seem to get the .htaccess redirect working.

    Here is what I have:
    RewriteEngine On
    RewriteRule ^/$ /owncloud/ (leftbracket)R(rightbracket)

    I had to write it that way on these forums due to anti-spam measures.


    I want people who go to domain.com to be redirected to domain dot com/owncloud/ but I'm just getting the Apache test page. I don't want to use methods which add the domain.com to the redirect rules because I want the web page to be accessible from inside my network by going to http 192.168.1.121 as well as domain dot com. At the same time, I want to be able to visit domain dot com/ajaxplorer/ or ipaddress/ajaxplorer/, so changing the base directory is not a good option.

    I have the latest versions of Apache, PHP, and MySQL for CentOS.

    Thank you in advance for your help.

  2. #2
    Join Date
    Jun 2003
    Location
    World Wide Web
    Posts
    581
    Please have a try using below codes in .htacess file

    ==================
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^domain\.com$ [OR]
    RewriteCond %{HTTP_HOST} ^www\.domain\.com$
    RewriteRule ^/?$ "http\:\/\/www\.domain\.com\/owncloud" [R=301,L]
    ===================
    SupportExpertz.com - the name says it all!
    Managed Cloud Servers
    Server Management and Monitoring
    24x7 outsourced customer support

  3. #3
    The only problem with that solution is that it assumes a certain domain. I want to be able to access the server from inside my LAN and outside. I might have to access it from the LAN IP address instead of the WAN domain name.

    I'm going to try something else. I will change the root apache directory to /owncloud and put a symbolic link in that folder to the /ajaxplorer directory. I'm thinking that should achieve what I'm trying to do.

    I will test it when I get to work tomorrow.

  4. #4
    Join Date
    Feb 2005
    Location
    Australia
    Posts
    5,842
    The other problem with the above is it'll send you into an endless redirect loop.

    Try this:
    Code:
    RewriteEngine On
    RewriteCond %{REQUEST_URI} !/owncloud/
    RewriteCond %{REQUEST_URI} !/ajaxplorer/
    RewriteRule (.*) /owncloud/$1 [L,R]
    Add any other directories you want excluded from the rule with similar RewriteCond lines. The other thing you might consider is removing the final R to make it an invisible rewrite instead of a redirect, ie. the url in the user's browser remains domain.com/ but internally you're serving the content from domain.com/owncloud/.
    Chris

    "Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them." - Laurence J. Peter

  5. #5
    Thanks for trying, Foobic, but that didn't work either. I still got the Apache test page. I don't understand what is going on, but it seems as if my .htaccess file is simply being ignored.

    I ended up changing the html root directory to /owncloud and added a symbolic link in there to ajaxplorer. That had the desired effect and I'm just going to leave it like that.

  6. #6
    Join Date
    Aug 2001
    Posts
    5,067
    mod_alias might be sufficient
    Sitemeer.com - Is your site up?
    Multi-Location Service Availability Check ● yes, we do HTTPS & IDN!


  7. #7
    Join Date
    Feb 2005
    Location
    Australia
    Posts
    5,842
    Quote Originally Posted by Syntax42 View Post
    I don't understand what is going on, but it seems as if my .htaccess file is simply being ignored.
    The default setting in httpd.conf may well be AllowOverride None, which would mean exactly that. Glad you've found a solution anyway.
    Chris

    "Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them." - Laurence J. Peter

Similar Threads

  1. Htaccess Redirect
    By ashras99 in forum Web Design and Content
    Replies: 7
    Last Post: 06-28-2012, 07:50 AM
  2. .htaccess https redirect different than http redirect
    By MTO in forum Hosting Security and Technology
    Replies: 4
    Last Post: 05-24-2012, 05:14 AM
  3. .htaccess redirect help
    By minhmeo in forum Web Hosting
    Replies: 4
    Last Post: 10-29-2011, 11:42 PM
  4. .htaccess redirect
    By acctman in forum Programming Discussion
    Replies: 2
    Last Post: 05-12-2009, 07:21 PM
  5. how to .htaccess redirect
    By wmicro in forum Programming Discussion
    Replies: 7
    Last Post: 12-15-2006, 09:34 PM

Posting Permissions

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