• There is an important update regarding account security and 2FA. Please click here for more information.
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.
  • Imgur has blocked certain regions from viewing any images uploaded to their site. If you use Imgur, please consider replacing any image links/embeds you may have on PokéCommunity so everyone can see your images. Click here to learn more.

Mod_Rewrite Help

  • 576
    Posts
    20
    Years
    • Seen Mar 14, 2008
    Can some one teach me mod_rewrite to rewrite my PHP URL?s in Html? I did read a tutorial in phpfreaks website but I am not that knowledgeable in all these matters. So, can some one post it here about how to do it? Thank you very much!

    One mroe doubt
    Code:
    <?php
       if (!$id) {
       $id = "main";
       $include = $id . ".txt";
       }
       else {
       $include = $id . ".html";
       }
       if (is_file($include) == "1") {
               include $include;
       }
       else {
       include "404.txt";
       }
       ?>

    If I change this to

    Code:
    <?php
       if (!$page) {
       $page = "main";
       $include = $page . ".txt";
       }
       else {
       $include = $page . ".html";
       }
       if (is_file($include) == "1") {
               include $include;
       }
       else {
       include "404.txt";
       }
       ?>
    Can I use index.php?page=blahblah.

    Also what should my cutenews archives file is a .php file . Since my include tag includes only HTML files, what should I do to make it show .php files?

    ~ CC

    ~ CC
     

    I see your pages are things like https://pokedrome.info/index.php?id=blah

    So what you need to do is:

    Open or create your .htaccess file (this is a text file named .htaccess) in your public_html directory.

    Add the following lines of code to it:
    Code:
    RewriteEngine On
    Options +FollowSymlinks
    RewriteRule ^(.*).php /index.php?id=$1

    See if that works.
     

    Add the following lines of code to it:
    Code:
    RewriteEngine On
    Options +FollowSymlinks
    RewriteRule ^(.*).php /index.php?id=$1

    I added the exact code you gave me in the .htaccess file but when I try to open my site I encounter 500 Internal server errors. Is it due to my host or anything. I also saw phpfreaks and added this code
    Code:
    RewriteEngine On
    RewriteRule ^/(.*).php/index.php?id$1
    but with no avail.

    ~ CC1
     

    *giggle* 500 errors are VERY familiar to me when it comes to mod_rewrite. What host are you on?
     


    Because it may have a script like PHPSuExec which causes the errors installed.
     

    Mihopa has no such thing :surprised
     

    Hm..... is your .htaccess file in the right folder? skds, if you work for Mihopa, could you have a look at it for him then?
     


    Back
    Top