Page 1 of 2 12 Last
  • Jump to page:
    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2009
    Posts
    50
    Rep Power
    0

    Mod_rewrite assistance


    Hello everyone,

    mod_rewrite is enabled and working.

    Joomla is installed under "example.com/_usr/example1". What I would like to achieve is to never have the public see "_usr/example1" anymore, so just "example.com" and of course any trailing pages that I create in the future.

    End result = Removal of "_usr/example1".

    I tried the following code, but it never worked and I'm sure I'm far off from the solution.

    RewriteEngine On
    Options +FollowSymLinks
    RewriteRule ^_usr/example1/ http://example.com/? [R=301,L]

    Any assistance would be greatly appreciated!
  2. #2
  3. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,183
    Rep Power
    9398
    Can't you just change the virtualhost (or regular host) to use that as the document root instead?
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2009
    Posts
    50
    Rep Power
    0
    Good question, but no unfortunately. I am able to do it for all except this one as this one is the main host.
  6. #4
  7. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,183
    Rep Power
    9398
    Have it rewrite everything into that directory (except for stuff actually in that directory); what you have now tries to rewrite out of it.
    Code:
    RewriteRule ^(?!_usr/example1) _usr/example1${REQUEST_URI} [L]
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2009
    Posts
    50
    Rep Power
    0
    No go sorry...

    Code:
    Not Found
    
    The requested URL /_usr/example1${REQUEST_URI} was not found on this server.
    
    Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
  10. #6
  11. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,183
    Rep Power
    9398
    That $ should be a %. Damn Apache and it doing variables in a weird way.
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2009
    Posts
    50
    Rep Power
    0
    Thanks requinix, but unfortunately its still not working. Below is the code I used to confirm... Is there a condition I should be using with this rule? Sorry, this is all new to me so its a lot to take in.

    Code:
    RewriteRule ^(%!_usr/example1) _usr/example1${REQUEST_URI} [L]
  14. #8
  15. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,183
    Rep Power
    9398
    I don't know what you did there so lemme just post the correct version.
    Code:
    RewriteRule ^(?!_usr/example1) _usr/example1%{REQUEST_URI} [L]
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2009
    Posts
    50
    Rep Power
    0
    Hmmm it never liked that very much... Shot out a 500 Internal Error. Do you think the problem could be with Joomla? I enabled both of the required fields, SEO URLs and URL ReWriting.
  18. #10
  19. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,183
    Rep Power
    9398
    Have you checked the error logs to see what is causing the 500s?
  20. #11
  21. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2009
    Posts
    50
    Rep Power
    0
    This may be a silly question, but should I be placing the .htaccess file under the root of "example.com" or under "example.com/_usr/example1"?

    As of now I have the root (example.com) setup to redirect it over to (example.com/_usr/example1), and then the under (example.com/_usr/example1) I have your code.
  22. #12
  23. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,183
    Rep Power
    9398
    What it's changing is how the root of the website behaves so the code should go in the root .htaccess. But putting it somewhere else shouldn't cause a 500 (it just wouldn't do any rewriting) so still check the logs.

    So how it goes is like this:
    1. User goes to example.com/some/path
    2. The root .htaccess has a RewriteRule which says
    Anything that doesn't start with "_usr/example1" should be rewritten as "_usr/example1" + the original request path.
    3. The new URL is now example.com/_usr/example1/some/path
    4? The root .htaccess has that same RewriteRule, but this time the path does start with "_usr/example1" so nothing happens
    5. Joomla has its own URL rewriting scheme which turns the relative "/some/path" into something (such as index.php?path=some/path)

    #4 may not happen, I'm still unsure how the whole process works and how [L] and [N] affect it.

    Note how there isn't any redirecting, just rewriting. The former will actually send the user someplace while the latter happens behind the scenes.
  24. #13
  25. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2009
    Posts
    50
    Rep Power
    0
    Very well written requinix,

    My apologies if I explained my issue improperly. What I need may be the oposite of what you have offered. I'm trying to figure out how to have it setup as "example.com/some/path". Currently is works as "example.com/_usr/example1/some/path".

    See, its installed under "example.com/_usr/example1" but I wish to have it displayed to the public as if it was installed under "example.com".
  26. #14
  27. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,183
    Rep Power
    9398
    Yeah... That's what I've been going with so far. Everything I've said and posted is for that idea.

    The user will still see example.com/some/path but Apache and Joomla will see it as example.com/_usr/example1/some/path. That's how URL rewriting works.
  28. #15
  29. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2009
    Posts
    50
    Rep Power
    0
    Here is my .htaccess code within the root (/) directory.
    Code:
    # Begin default subdomain redirect # RewriteEngine on # End default subdomain redirect #  <Files *> # Begin varnish cache - disables server cache # Header set Cache-Control: "private, pre-check=0, post-check=0, max-age=0" Header set Expires: 0 Header set Pragma: no-cache # End varnish cache # </Files>  # Modify the RewriteBase if you are using Joomla in a subdirectory or in a # VirtualDocumentRoot and the rewrite rules are not working properly. # For example if your site is at http://example.com/joomla uncomment and # modify the following line: RewriteBase /  RewriteRule ^(?!_usr/example1) _usr/example1%{REQUEST_URI} [L]
    Here is the Error Log
    Code:
    [Tue Sep 18 03:49:09 2012] [error] [client 184.171.206.20] File does not exist: /var/chroot/home/content/87/9580087/html/_usr/example1/missing.html [Tue Sep 18 04:31:31 2012] [error] [client 76.11.82.16] File does not exist: /var/chroot/home/content/87/9580087/html/_usr/example1/_usr [Tue Sep 18 04:31:31 2012] [error] [client 76.11.82.16] File does not exist: /var/chroot/home/content/87/9580087/html/_usr/example1/_usr [Tue Sep 18 04:31:38 2012] [error] [client 76.11.82.16] File does not exist: /var/chroot/home/content/87/9580087/html/_usr/example1/_usr [Tue Sep 18 04:31:38 2012] [error] [client 76.11.82.16] File does not exist: /var/chroot/home/content/87/9580087/html/_usr/example1/_usr
    Last edited by Wayniac; September 18th, 2012 at 03:40 PM.
Page 1 of 2 12 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo