Converting HTML pages for PHP script without altering URL

Discussion in 'PHP' started by amanamission, Oct 29, 2007.

  1. #1
    I am planning to install Aardvark PHP on many of my pages which are currently static. The problem is that new pages created by the script are not customizable. Instead, the script produces

    http://www.domain.com/index.php?a=page&id=pagetitle

    where I need to have:

    http://www.domain.com/pagetitle.htm

    in order to utilize my established pages.

    I have been wrestling in vain with this, trying variou mod_rewrite formulas, but nothing seems to work. I would think this is a simple matter, but now I wonder if the script is overwriting my URL's because it is harmful to the script to change them.
    The more I learn, the more confused I become. Static pages are concrete, I can go to them and make my changes-but a dynamic page doesn't even exist, in the sense of a physical file on my server.

    Is it dangerous to some scripts to rewrite the URL? What is the best method for navigating this? I have looked at PHP rewrites, but the ones i see are all too complex and not applicable.
    This is a very simple rewrite...I only want to change the URL's as above without disturbing any other pages or the SE positioning of the pages I plan to convert. So I'm wondering if I'm missing something.
     
    amanamission, Oct 29, 2007 IP
  2. schoash

    schoash Active Member

    Messages:
    291
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    55
    #2
    You can try to extract the
    URL with an extra script and set the various $_GET and $_POST according to what you need b4 you run the actual script..
     
    schoash, Oct 29, 2007 IP
  3. amanamission

    amanamission Notable Member

    Messages:
    1,936
    Likes Received:
    138
    Best Answers:
    0
    Trophy Points:
    210
    #3
    Wouldn't that break the script? I assume they made it that way for a reason.

    I think I have source code on it, script is open source, want to take a crack at forking it?
     
    amanamission, Oct 29, 2007 IP
  4. schoash

    schoash Active Member

    Messages:
    291
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    55
    #4
    well at the moment i am at work.. i can have a look later
     
    schoash, Oct 29, 2007 IP
  5. dadougalee

    dadougalee Peon

    Messages:
    589
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #5
    just do a mod_rewrite

    In your root add a .htaccess file. In the file add this code:
    RewriteEngine On
    RewriteRule ^/(.*).htm$ /index.php?a=page&id=$1

    I'm pretty sure it is something like that though. You are prolly going to need to see if your server supports mod_rewrites
     
    dadougalee, Oct 29, 2007 IP
  6. amanamission

    amanamission Notable Member

    Messages:
    1,936
    Likes Received:
    138
    Best Answers:
    0
    Trophy Points:
    210
    #6
    Yeah, I've been trying that. The problem is that I need to convert pages in several styles: I have pages which are .htm, others .html, and other that are folders. And I have other pages that will be wordpress or static on the same domain that I do not want to rewrite.
    Best solution would be a mod or plugin for custom permalinks, like Wordpress. This is a pretty widely used script, I think it would be fairly popular if someone wants to give it a shot.
    @schoash: If you do this, I will get you some high quality links and promote your mod at the support forum if you like. Please PM me and we'll discuss this. Sending PM.
     
    amanamission, Oct 29, 2007 IP
  7. dadougalee

    dadougalee Peon

    Messages:
    589
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Sorry, but I am unfamiliar with wordpress.
     
    dadougalee, Oct 30, 2007 IP
  8. gordi555

    gordi555 Active Member

    Messages:
    537
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    58
    #8
    This is what I do...

    1. First I modify the .htaccess to lookup a file if a url is not found...

    
    Options -Indexes
    DirectoryIndex index.php index.html index.htm
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ read.php [L,QSA]
    
    PHP:
    This says "if i can't find it, let read.php try and sort it out".

    2. read.php
    
    
    $TheURL = $_SERVER['REQUEST_URI'];
    $var_array = explode("/",$TheURL);
    $GotURL = $var_array[1]; //domain.com/url/
    //print $GotURL;
    $articlesql = mysql_query("SELECT *, date_format(DateTime,'%W, %D %M %Y') as DateTime1 FROM project_blog_entry WHERE URL = '" . mysql_real_escape_string($GotURL) . "'");
    
    
    PHP:
    So you can see that if you store the urls in the db then you can look them up.

    May help may not but hope it does.
     
    gordi555, Oct 30, 2007 IP
  9. M@fia

    M@fia Active Member

    Messages:
    130
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #9
    hi
    i dont work with database
    i need something like this
    domain.com/index.php?q=digitalpoint
    =
    domain.com/digitalpoint.html
    tnx
     
    M@fia, Jan 21, 2008 IP