#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    31
    Rep Power
    2

    URL rewriting broken -- subfolder works, root folder doesn't


    I feel like this should be an easy bug to fix, but I don't see it. I am very new to Apache and rewrite rules.

    I have three four on my site. Two use a multi-site wordpress install, one uses Elgg and the fourth is codeigniter.
    /social/ -> elgg
    /actions/ -> codeigniter
    /about/ -> wordpress
    /academy/ -> wordpress

    My problem is in the /social/ rewrite. Everything else works. I actually removed everything else and the social rewrite gives me a problem. What I need is for
    /social -> /elgg-core/
    /social/ -> /elgg-core/
    /social/whatever -> /elgg-core/whatever
    /whatever/ -> /elgg-core/profile/whatever

    Here is what I have:

    Code:
    ### Third, check for the social module
    RewriteRule ^social(.+)$ elgg-core/$1 [NC,L]
    
    ### Last, look for a user profile or 404 error
    RewriteRule ^(.+)$ elgg-core/profile/$1 [NC,L]
    The profile rewrite works and anything like /social/whatever works, but the /social and /social/ give me 404 errors.

    Any help would be greatly appreciated

    Here is the code in context, if needed

    Code:
    <IfModule mod_rewrite.c>
    
    RewriteEngine On
    
    ### Where do we begin?
    RewriteBase /dmgconnect/
    
    ### Where is the wordpress multisite file?
    RewriteRule ^wordpress\.php$ - [L]
    
    ### add a trailing slash to /wp-admin
    RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
    
    ### Set our conditions
    RewriteCond $1 !^(index\.php|images|robots\.txt)
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d 
    
    #### URL Rewrite Rules
    ### First, check for wordpress sites (about, academy)
    RewriteRule ^ - [L]
    
    # Rewrite the wordpress admin stuff
    RewriteRule ^(.+)/?(wp-(content|admin|includes).*) wp-core/$2 [L] #
    RewriteRule ^(.+)/?(.*\.php)$ wp-core/$2 [L]
    
    # Rewrite for the two sites (if more added, we must rewrite for them specifically
    RewriteRule ^about(.+) wordpress.php [L]
    RewriteRule ^academy(.+) wordpress.php [L]
    
    
    ### Second, is there anything for CodeIgniter specifically?
    RewriteRule ^actions/(.+)$ index.php/$1 [NC,L]
    
    
    ### Third, check for the social module
    RewriteRule ^social(.+)$ elgg-core/$1 [NC,L]
    
    
    ### Last, look for a user profile or 404 error
    RewriteRule ^(.+)$ elgg-core/profile/$1 [NC,L]
    
    </IfModule>
    Last edited by chrismichaels84; February 20th, 2013 at 01:24 PM. Reason: Clarification
  2. #2
  3. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,068
    Rep Power
    9398
    .+ means one or more characters. Sounds like you want .* meaning zero or more characters.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    31
    Rep Power
    2
    Thanks for the reply. That gets me somewhere, but I'm still getting a strange 404.

    My problem is in the /social/ rewrite. Everything else works. I actually removed everything else and the social rewrite give me a problem. What I need is for
    /social -> /elgg-core/
    /social/ -> /elgg-core/
    /social/whatever -> /elgg-core/whatever
    /whatever/ -> /elgg-core/profile/whatever

    Here is what I have:

    Code:
    ### Third, check for the social module
    RewriteRule ^social(.+)$ elgg-core/$1 [NC,L]
    
    ### Last, look for a user profile or 404 error
    RewriteRule ^(.+)$ social/profile/$1 [NC,L]
    The profile rewrite works and anything like /social/whatever works, but the /social and /social/ give me 404 errors.

    Thanx
  6. #4
  7. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,068
    Rep Power
    9398
    Like I said, it sounds like you should be using .*

    Also consider how "social/" will be rewritten to "elgg-core//". Note the second slash. That may be causing your 404. Try a structure more like
    Code:
    RewriteRule ^social(/.*)? elgg-core$1 [NC,L]
    That is, "social" may be by itself but if not then it has to be followed by at least a slash.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    31
    Rep Power
    2
    Thank you, I believe that took care of it!

IMN logo majestic logo threadwatch logo seochat tools logo