1and1 and mod_rewrite

Discussion in 'Apache' started by leony, Jun 18, 2008.

  1. #1
    Hi

    I am having a weird mod_rewrite problem with 1and1. The following code works on another hosting company's server but on 1and1 I get error 404. Can you please help what might be the problem?

    Thanks.
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <h2 align=center>
    <?
    // mod_rewrite Test Page
    // Copyright 2006 Webune.com
    if($_GET['link']==1){echo"You are not using mod_rewrite";}
    elseif($_GET['link']==2){echo"Congratulations!! You are using Apache mod_rewrite";}
    else{echo"Linux Apache mod_rewrte Test Tutorial";}
    ?>
    </h2>
    
    <hr>
    
    <head>
    <title>How To Test mod_rewrite in Apache Linux Server</title>
    </head>
    
    <body>
    <p align="center">by <a href="http://www.webune.com">Webune</a></p>
    <p><a href="rewrite.php?link=1">LINK1</a> = rewrite.php?link=1</p>
    <p><a href="link2.html">LINK2</a> = link2.html</p>
    <p>How this works: both links are for this same page, except they both are different. link one is without the mod_rewrite and link2 is using mod_rewrite. Link1 show the php file, with with mod_rewrite we are mascarading the php file into a html file. you can use whatever type of extension you want, you can change it to .htm or .shtml etc... all you have to do is to make sure you also chang it in the .htaccess file</p>
    <p>&lt;&lt; <a href="http://www.webune.com/forums/how-to-test-check-if-mod-rewrite-is-enabled-t40.html">Go back to webune forums.</a></p>
    </body>
    </html> 
    
    Code (markup):
    and .htaccess file:

    
    RewriteEngine On
    RewriteRule ^link([^/]*).html$ rewrite.php?link=$1 [L]
    
    Code (markup):
    Thank you for your help.
     
    leony, Jun 18, 2008 IP
  2. Goodlookinguy

    Goodlookinguy Peon

    Messages:
    5
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    One and One doesn't allow PHP short tags. I've used them for quite a while and I haven't had short tags work at all.

    You have to go the extra 3-letters mile. Example:
    <?php phpinfo() ?>
    Code (markup):
     
    Goodlookinguy, Jun 18, 2008 IP
  3. leony

    leony Peon

    Messages:
    55
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Sorry, I did not get why it has effect on mod_rewrite.

    Can you please correct the PHP code I posted for 1and1 then?

    Thanks.
     
    leony, Jun 19, 2008 IP
  4. Goodlookinguy

    Goodlookinguy Peon

    Messages:
    5
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Well, your entire HTML code was off really. Heads up, you can use either $_REQUEST or $_GET and either if conditions or switches.

    1&1 Basic through Company($3.99 package through $19.99 package) doesn't allow that particular mod rewrite, or any mod rewrite that changes the file completely like file?type=here to file2.html. My suggestion is to do as my example below shows.

    <Files rewrite.html>
    ForceType x-mapp-php4
    </Files>
    Code (markup):
    What this does is treat the file "rewrite.html" as a php file. You can't have complete rewrite on pages for some reason with the cheaper hosting at one and one. So, there you go, that is the best advice I can give ya. I suggest, however, that you completely hide your extension and force rewrite for all browsers from / to /index

    Anyways, here is a corrected XHTML file.

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>How To Test mod_rewrite in Apache Linux Server</title>
    </head>
    <body>
    <h2 align="center">
    <?php
    // mod_rewrite Test Page
    // Copyright 2006 Webune.com
    if ($_GET['link']==1) {
    	echo "You are not using mod_rewrite";
    	}
    elseif ($_GET['link']==2) {
    	echo "Congratulations!! You are using Apache mod_rewrite";
    	}
    else {
    	echo "Linux Apache mod_rewrte Test Tutorial";
    	}
    ?>
    </h2>
    <hr />
    <p align="center">by <a href="http://www.webune.com">Webune</a></p>
    <p><a href="?link=1">LINK1</a> = rewrite.php?link=1</p>
    <p><a href="link2.html">LINK2</a> = link2.html</p>
    <p>How this works: both links are for this same page, except they both are different. link one is without the mod_rewrite and link2 is using mod_rewrite. Link1 show the php file, with with mod_rewrite we are mascarading the php file into a html file. you can use whatever type of extension you want, you can change it to .htm or .shtml etc... all you have to do is to make sure you also chang it in the .htaccess file</p>
    <p>&lt;&lt; <a href="http://www.webune.com/forums/how-to-test-check-if-mod-rewrite-is-enabled-t40.html">Go back to webune forums.</a></p>
    </body>
    </html>
    Code (markup):
    I really don't have anymore advice. If you need more explanations I'll be glad to answer. Anymore questions, and I'll be glad to answer as well.

    Also, if I don't get back to you right away that is because I'm finishing up my summer school homework, I'm only sixteen.
     
    Goodlookinguy, Jun 19, 2008 IP