Results 1 to 3 of 3
  1. #1
    Join Date
    May 2002
    Posts
    46

    Question .htaccess for URL rewriting on 1and1

    I am trying to install a php script on 1and1's shared home package. The script uses url rewriting for search friendly URLS. but it seems that 1and1 servers handles .htaccess file differently because the same script is working perfectly fine on my other host.

    This is the actual .htaccess provided by the script:
    Code:
    RewriteEngine on 
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?rt=$1 [L,QSA]
    I changed it to following with getting idea from this thread but it did not work:

    Code:
    AddType x-mapp-php5 .php
    
    # 1and1 needed for php extensionless redirect.
    Options -MultiViews
    
    RewriteEngine on 
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}.php -f
    RewriteRule ^(.*)$ index.php?rt=$1 [L,QSA]
    I would be very thankful if you could sort out the issue. I have already mailed 1and1 support but I don't think I will get a response from them.

    the syntax of .htaccess is totally alien to me so I don't understand what does $1, [L,QSA] and other characters mean.
    Last edited by haris66; 08-19-2009 at 08:23 AM.

  2. #2
    Join Date
    May 2002
    Posts
    46
    forgot to tell you that the error is 404 not found.

  3. #3
    Join Date
    Feb 2005
    Location
    Australia
    Posts
    5,842
    The $1 means whatever is matched inside the brackets earlier on the same line (in this case, the page requested). In the square brackets at the end, L means "last" - stop processing here, QSA means "query string append", ie. add the "rt=pagerequested" to whatever else was in the query string already.

    But that's all standard stuff - the original file you posted should work on most servers. Evidently 1and1 have an unusual setup that makes it fail. If you look in the logs you should see the filename that gives the 404 error (which may or may not be the page you originally requested).

    One thing I'd try first would be to add a "RewriteBase" line (with or without the other mods you already tried), ie.
    Code:
    RewriteEngine on 
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?rt=$1 [L,QSA]
    (or if this is installed in a subdirectory, use "RewriteBase /subdirectory")

    Edit: also perhaps try RewriteRule ^(.*)$ /index.php... etc.
    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. Some Redirecting/Rewriting Problems wiht .htaccess
    By mammos in forum Web Design and Content
    Replies: 0
    Last Post: 09-12-2007, 02:43 PM
  2. htaccess rewrites not... well... rewriting.
    By Strike1011 in forum Programming Discussion
    Replies: 4
    Last Post: 07-21-2007, 08:45 PM
  3. mod_rewrite url rewriting.
    By lachtan in forum Hosting Security and Technology
    Replies: 3
    Last Post: 02-18-2005, 03:53 PM
  4. Address rewriting?
    By sbalmos in forum Hosting Security and Technology
    Replies: 1
    Last Post: 12-30-2004, 05:56 PM
  5. Mod Vhost & URL rewriting
    By netserve in forum Hosting Security and Technology
    Replies: 0
    Last Post: 05-18-2001, 06:41 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
  •