+ Reply to Thread
Results 1 to 5 of 5
Like Tree2Likes
  • 1 Post By atlanis
  • 1 Post By AngusThermopyle

Thread: mod_rewrite help

  1. #1
    atlanis is offline x10Hosting Member atlanis is an unknown quantity at this point
    Join Date
    Mar 2010
    Posts
    24

    mod_rewrite help

    I'm not sure if this is the right forum or not, but here goes.

    I have the following setup:
    Main Domain: http://atlanis.pcriot.com/
    Subdomain: http://evil.atlanis.pcriot.com/
    Subdomain root: /public_html/evil/

    /public_html/evil/.htaccess:
    Code:
    RewriteEngine On
    RewriteBase /
    RewriteRule ^/user/(.+)/?$ /sig.php?user=$1 [L]
    I'm trying to turn http://evil.atlanis.pcriot.com/user/maryjane into http://evil.atlanis.pcriot.com/sig.php?user=maryjane. I have verified that the substitution URL is working, but the rewritten version (/user/maryjane) is giving me a 404 error. What can I do to fix it? I read on the forums that free hosts have mod_rewrite, so it should work if my .htaccess is done right (which is apparently isn't).
    dinomirt96 likes this.

  2. #2
    AngusThermopyle is offline x10Hosting Member AngusThermopyle is an unknown quantity at this point
    Join Date
    Nov 2009
    Posts
    84

    Re: mod_rewrite help

    Code:
    RewriteEngine On
    RewriteCond %{REQUEST_URI}  ^/user/.*$
    RewriteRule ^user/(.*)$ sig.php?user=$1 [L]
    will work
    Last edited by AngusThermopyle; 03-16-2010 at 09:39 PM.
    karimirt47 likes this.

  3. #3
    atlanis is offline x10Hosting Member atlanis is an unknown quantity at this point
    Join Date
    Mar 2010
    Posts
    24

    Re: mod_rewrite help

    Quote Originally Posted by c.solomon View Post
    Code:
    RewriteEngine On
    RewriteCond %{REQUEST_URI}  ^/user/.*$
    RewriteRule ^user/(.*)$ sig.php?user=$1 [L]
    will work
    Thank you so much! It is working now!

  4. #4
    misson is offline Community Advocate misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,391

    Re: mod_rewrite help

    The rest of the story: the essential difference is the lack of a leading slash in the pattern. What's happening is that the rewrite engine has to handle per-directory rewrites (those set in .htaccess) differently than global rewrites (those in the conf files): it has to strip the directory prefix before processing, including a trailing slash. For example, the URL path "/user/fred" is translated to the file path "/home/atlanis/public_html/user/fred". For rewrite rules in "/home/atlanis/public_html/.htaccess", the "/home/atlanis/public_html/" is stripped from the file path, so the patterns are matched against "user/fred". If you want a pattern that works in any context, start it with "^/?" (e.g. "^/?user/(.+)/?".

    Read the mod_rewrite documentation for more, particularly the technical details and RewriteBase directive.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  5. #5
    atlanis is offline x10Hosting Member atlanis is an unknown quantity at this point
    Join Date
    Mar 2010
    Posts
    24

    Re: mod_rewrite help

    Okay, thanks a lot missen!

    *clicks links*

+ Reply to Thread

Similar Threads

  1. mod_rewrite
    By james2k8111 in forum Free Hosting
    Replies: 3
    Last Post: 11-02-2008, 12:56 PM
  2. mod_rewrite
    By sampuu in forum Free Hosting
    Replies: 3
    Last Post: 09-06-2008, 03:01 PM
  3. mod_rewrite
    By demiselegion in forum Free Hosting
    Replies: 1
    Last Post: 05-13-2008, 09:40 AM
  4. mod_rewrite
    By expose in forum Free Hosting
    Replies: 1
    Last Post: 05-01-2008, 09:46 PM
  5. mod_rewrite?
    By tondopie in forum Free Hosting
    Replies: 1
    Last Post: 03-23-2008, 11:52 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers