Jump to content

.htaccess to rewrite url > please help here....


gotit

Recommended Posts

I want to rewrite my dynamic URLs to static.

this is the example that my host is giving:
[color=red][font=Verdana]# Example for a rewrite rule:
# (turns http://domain.com/xyz.html into http://domain.com/index.php?xyz)
#
RewriteEngine on
RewriteBase /
RewriteRule ^([a-z]+)\.html$ /index.php?$1 [R,L][/font][/color]

This is the opposit of what I want to do.

My urls read like this
http://www.mydomain.com/system/listingView.php?listingCode=1053
I would like to change the code above given as a sample by the host to rewrite this URL into static.



Link to comment
Share on other sites

Thanks,
I loaded the file to system folder with this code.

RewriteEngine on
RewriteBase /
RewriteRule ^system/listing/([0-9+])/$ /system/listingView.php?listingCode=$1

But i still get error
I called the tech support and they say we do support mode rewrite, and the error looks like is from script and we don't provide script help.

INTERNAL SERVER ERROR
An internal server error has occured!
Please try again later.


Link to comment
Share on other sites

Try that:
[code]RewriteEngine on
RewriteBase /
RewriteRule ^system/listing/([0-9]+)$ /system/listingView.php?listingCode=$1[/code]

Do you still get the internal server error? If you do check your servers error logs. It should be logged near the end of the log. Post it here.
Link to comment
Share on other sites

A few hosts do not allow mod rewrite on shared hosting servers - They moan about some security but I don't think it's that much of an issue.

Some will demand u have a dedicated server but personally I think this is all a bit un justified.

They simply need to ensure AllOverride FileInfo is set on your directory in the apache config file which can be done easily and if they use anything like plesk then this can be set as default.

Good luck finding a host that will allow you to use this wonderful tool.
Link to comment
Share on other sites

[color=red]I did upload the new code, still getting error bellow.[/color]Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webadmin@kundenserver.de and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.


Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request

I spoke to hosting many times, they insist that they support mode rewrite and something wrong with my script.


Link to comment
Share on other sites

[quote author=wildteen88 link=topic=119322.msg489141#msg489141 date=1166646036]
Try that:
[code]RewriteEngine on
RewriteBase /
RewriteRule ^system/listing/([0-9]+)$ /system/listingView.php?listingCode=$1[/code]

Do you still get the internal server error? If you do check your servers error logs. It should be logged near the end of the log. Post it here.
[/quote]

I got error again, see above post.

74.96.71.69 - - [20/Dec/2006:23:07:36 -0500] "GET / HTTP/1.1" 500 - www.mywebsite.com "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)" "-"
74.96.71.69 - - [20/Dec/2006:23:07:39 -0500] "GET / HTTP/1.1" 500 - www.mywebsite.com "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)" "-"
74.96.71.69 - - [20/Dec/2006:23:07:45 -0500] "GET / HTTP/1.1" 500 - www.mywebsite.com "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)" "-"
66.249.66.163 - - [20/Dec/2006:23:10:01 -0500] "GET /system/proCategory.php?mainCategory=106&subCategory=108 HTTP/1.1" 500 - www.mywebsite.com "-" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" "-"
66.94.237.181 - - [20/Dec/2006:23:10:44 -0500] "GET /tinc?key=VhV88EZb HTTP/1.0" 500 - mywebsite.com "-" "YahooFeedSeeker/2.0 (compatible; Mozilla 4.0; MSIE 5.5; http://publisher.yahoo.com/rssguide; users 0; views 0)" "209.131.37.237"
Link to comment
Share on other sites

I found this in the Host web site:

Creating own error logs for debugging php scripts.


Since we dont provide access to Apache error logs on shared hosting packages for
technical reasons, you can create your own error logs for debugging PHP Scripts.

Please insert the following code in your PHP script (or create separate file and
and add the code in it. Include the file using [b]"include()")[/b]    [color=orange]<-------------------This i don't know wha it means !!![/color]

           
  error_reporting(0);
  $old_error_handler = set_error_handler("userErrorHandler");

  function userErrorHandler ($errno, $errmsg, $filename, $linenum,  $vars)
  {
    $time=date("d M Y H:i:s");
    // Get the error type from the error number
    $errortype = array (1    => "Error",
                        2    => "Warning",
                        4    => "Parsing Error",
                        8    => "Notice",
                        16  => "Core Error",
                        32  => "Core Warning",
                        64  => "Compile Error",
                        128  => "Compile Warning",
                        256  => "User Error",
                        512  => "User Warning",
                        1024 => "User Notice");
      $errlevel=$errortype[$errno];

      //Write error to log file (CSV format)
      $errfile=fopen("errors.csv","a");
      fputs($errfile,"\"$time\",\"$filename:
      $linenum\",\"($errlevel) $errmsg\"\r\n");
      fclose($errfile);

      if($errno!=2 && $errno!=8) {
        //Terminate script if fatal errror
        die("A fatal error has occured. Script execution has been aborted");
      }
  }

         


Link to comment
Share on other sites

I made this file and named it error log and loaded it in a folder: PHP file

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<?
include("../system/.htaccess");
?>

<?
error_reporting(0);
  $old_error_handler = set_error_handler("userErrorHandler");

  function userErrorHandler ($errno, $errmsg, $filename, $linenum,  $vars)
  {
    $time=date("d M Y H:i:s");
    // Get the error type from the error number
    $errortype = array (1    => "Error",
                        2    => "Warning",
                        4    => "Parsing Error",
                        8    => "Notice",
                        16  => "Core Error",
                        32  => "Core Warning",
                        64  => "Compile Error",
                        128  => "Compile Warning",
                        256  => "User Error",
                        512  => "User Warning",
                        1024 => "User Notice");
      $errlevel=$errortype[$errno];

      //Write error to log file (CSV format)
      $errfile=fopen("errors.csv","a");
      fputs($errfile,"\"$time\",\"$filename:
      $linenum\",\"($errlevel) $errmsg\"\r\n");
      fclose($errfile);

      if($errno!=2 && $errno!=8) {
        //Terminate script if fatal errror
        die("A fatal error has occured. Script execution has been aborted");
      }
  }
?>
</body>
</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.