Results 1 to 7 of 7
  1. #1
    Join Date
    Oct 2003
    Location
    Worldwide!
    Posts
    281

    .htaccess ReWrite engine fails

    PHP Code:
     Options +FollowSymlinks 
    RewriteEngine on
    RewriteOptions inherit

    RewriteCond 
    %{REQUEST_FILENAME}  -d
    RewriteRule  
    ^.*$  -  [L]

    RewriteRule ^/(.*)$    ../viewpofile.php?user=$[L
    I have put in a folder /users/ (Of which is on a subdomain) however every time I goto users.domain.com/myusername I just get a 404 error. That PHP file is there. I even copied it into the user dir and renamed it do it was /viewprofile.php and still 404 error.

    Any idea's?

    Thanks
    PhoneSupportWorldwide.com
    Web Hosting Telephone Customer Services
    Telephone: 0800 310 2729 - Blog: Click here

  2. #2
    Join Date
    Aug 2005
    Location
    Canada
    Posts
    838
    RewriteRule ^/(.*)$ ../viewpofile.php?user=$1 [L]

    I don't think you can use ../ in the substitution.
    Also, if you are using the rule in .htaccess, ^/(.*)$ will not match.

  3. #3
    Join Date
    Oct 2003
    Location
    Worldwide!
    Posts
    281
    Quote Originally Posted by extras
    RewriteRule ^/(.*)$ ../viewpofile.php?user=$1 [L]

    I don't think you can use ../ in the substitution.
    Also, if you are using the rule in .htaccess, ^/(.*)$ will not match.
    Hello,

    I tried it with the file in the same location without the slashes and still does not work.

    If
    ^/(.*)$
    is incorrect what is the best replacement for it?

    Basically I want it so people can go users.domain.com/theusername and it goes to viewprofile.php?username=theusername

    Thanks,

    James
    PhoneSupportWorldwide.com
    Web Hosting Telephone Customer Services
    Telephone: 0800 310 2729 - Blog: Click here

  4. #4
    Join Date
    Aug 2005
    Location
    Canada
    Posts
    838
    RewriteRule is influenced by many factors.
    To determine exact rule, you need to show entire .htaccess of all directories concerned.
    Otherwise, we can miss small detail and the rule may fail.

    Having said that, if the "viewpofile.php" is in the document root, this may do.
    RewriteRule ^/*(.*)$ /viewpofile.php?user=$1 [L]

  5. #5
    Join Date
    Oct 2003
    Location
    Worldwide!
    Posts
    281
    Hey Extra's..

    When I use that I get a

    HTTP 500 Internal Server Error

    Any idea's?

    Thanks..
    PhoneSupportWorldwide.com
    Web Hosting Telephone Customer Services
    Telephone: 0800 310 2729 - Blog: Click here

  6. #6
    Join Date
    Aug 2005
    Location
    Canada
    Posts
    838
    As you don't show much data, it's hard to say.
    When you report back, show exactly what you did, what you got as result.

    Check your error log, first.
    It will tell you the cause in some cases.

    Common mistakes are:
    Wrong FTP transfer mode causing bad line ending. ==> make sure to use ascii transfer.
    Syntax error somewhere.
    Using Directive of modules not loaded.


    If you are putting that in .htaccess, use RewriteBase and remove slash from substitution.
    RewriteBase /
    RewriteRule ^/*(.*)$ viewpofile.php?user=$1 [L]

    Or, add loop stopper.
    RewriteCond %{REQUEST_URI} !/viewpofile.php
    RewriteRule ^/*(.*)$ /viewpofile.php?user=$1 [L]

    These will remedy the 500 error if it's caused by looping.
    Last edited by extras; 11-24-2005 at 12:16 PM.

  7. #7
    Join Date
    Apr 2002
    Location
    Denver, Colorado
    Posts
    269
    what are you trying to match? have you read the mod_rewrite docs thoroughly?

Posting Permissions

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