1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to mod_rewrite “ONE file” from .php to .html in .htaccess?

Discussion in 'Apache' started by Mr Goldwing, Feb 28, 2017.

  1. #1
    What is the syntax to mod_rewrite "ONE file" from upload.php to upload.html in .htaccess? I have syntax for ALL files, but how do I do that for one file? I tried many other variations but still nothing. I just keep getting a page that says: MULTIPLE CHOICES. file not found...etc.

    Right now upload file must be a php in order to work but I want the address in the browser address bar to say upload.html because that page has google ranking. Yes, I know I can 301 redirect but I want to see how this can be done with htaccess

    THanks
    SEMrush
     
    Mr Goldwing, Feb 28, 2017 IP
    SEMrush
  2. Tanya Roberts

    Tanya Roberts Active Member

    Messages:
    250
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    75
    #2
    Well this thing looks working
    
    RewriteEngine on
    RewriteBase /
    RewriteRule ^upload\.html$ upload.php
    
    Code (markup):
    Make sure the RewriteBase is the folder name you are in. This will just execute upload.html as upload.php and supports any function similar to upload.php
     
    Tanya Roberts, Mar 3, 2017 IP
  3. Mr Goldwing

    Mr Goldwing Well-Known Member

    Messages:
    519
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    108
    #3
    Thanks you so much
     
    Mr Goldwing, Mar 5, 2017 IP
  4. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,630
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #4
    And, just in general, and to avoid unnecessary server load for rewrites and such, just make a plain upload.html HTML file, and process the upload in upload.php (linked from the upload-form).
     
    PoPSiCLe, Mar 5, 2017 IP
  5. Mr Goldwing

    Mr Goldwing Well-Known Member

    Messages:
    519
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    108
    #5
    For the form to make the upload work, it has to be in php because it looks for a token. This is the beginning of the file that must be used:
    <?php
    
        require dirname(__FILE__)."/uploads/php/csrf.php";
        $new_token = new CSRF('contact');
    
    ?>
    Code (markup):
    and the rest is pretty simple processing script. Im not really a coder but Im trying to make sense out of this.
     
    Mr Goldwing, Mar 5, 2017 IP