I'm creating a webcomic site, however the chapter order has transformed considerably. I've by hand written the conversions personally inside a form such as this:

36 -> 26.1

37 -> 28

38 -> 28.1

39 -> 29

40 -> 30

41 -> 30.1

Essentially, after this guide, I wish to convert all web addresses like http://www.domain.com/view.php?chapter=38 towards the more recent kind like http://www.domain.com/c28.1.

I should also make sure that individuals asking for a webpage number, like view.php?chapter=38&page=4 get their page amounts passed onto the redirect, like so: c28.1/p4.html.

It might appear really quite simple, with the exception that I've 70 approximately of those to implement, and am just a little worried if the considerably affects site performance (is 70 a great deal..?) and should not obtain the comic and page variables to correctly rewrite.

So my real question is, how do you accomplish this, what's my best answer? If performance isn't any problem, I would rather ensure that it stays within the .htaccess with my other mod_rewrite code, but when the only real reasonable method of doing it's write b .perl script and ask it to complete the redirect, I'm able to do this - though I do not really understand how to get PHP to achieve that.

Please bear in mind the 70 approximately pointed out would be the only ones I'll have, and so i don't choose to make an easily-accessible database. Among the finest the redirects to utilize minimal fuss.

I'll be so grateful for just about any response. Thanks ahead of time if anybody might help me figure that one out.

I believe a lighter way (when it comes to rows inside .htaccess file) to approach is, as if you have pointed out, to make use of .htaccess to deal with web addresses like:

RewriteRule ^c([0-9]+)$ view.php?chapter=$1  
RewriteRule ^c([0-9]+).([0-9]+)$ view.php?chapter=$1&section=$2  
RewriteRule ^c([0-9]+).([0-9]+)/p([0-9]+).html$ view.php?chapter=$1&section=$2&page=$3

After which map these to a php script which will handle the only contents.

I'm able to suggest you that you ought to also have to map by rewriterule having a 301 redirect all of the old web addresses to be able to allow people who are from a internet search engine serp to become rerouted right new link to this content.

Hope this can help.

I wound up talking to using the wonderful people of freenode #httpd and also got an answer. For me personally, when i simply want to catch demands for view.php, I discovered it labored to merely write a view.php script that collected things from an assortment. No mod_rewrite necessary. The script I'm now using appears like:

<?

$chapters = array(
    // old => new
    1   => 2,
    2   => 3,
    3   => 4,
    10  => 21
);

if (! isset($_GET['chapter']) || ! isset($chapters[$chapter = (int)$_GET['chapter']])) {
    header('HTTP/1.1 404 Not Found');
    echo 'Page Not Found';
    exit;
}

$url = '/c' . $chapters[$chapter];
if (isset($_GET['page']))
    $url .= '/p' . $_GET['page'] . '.html';

header('Location: ' . $url, 301);

?>

Interesting help, though, gh3.