RewriteRule Help Please

5 replies
Can you brilliant programs on here tell me how to appending .html to this .httaccess rewrite rule? I've messed with it but not working. Thanks in advance.

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mysite\.net [NC]
RewriteRule (.*) http://www.mysite.net/$1 [L,R=301]
RewriteRule ^index.html index.php
RewriteRule ^mp3/(.*)-([0-9]+)$ mp3s.php?search=$1&page=$2
RewriteRule ^mp3/(.*)$ mp3s.php?search=$1
</IfModule>
#rewrite #rewriterule #rule
  • Profile picture of the author KirkMcD
    Append it where?
    What are you trying to do?
    {{ DiscussionBoard.errors[6903957].message }}
  • Profile picture of the author mathieu67
    at the end of the search results. The site is Download Free Mp3 Music Songs Legally. At the end of the search results I would like to at .html to the URLs.
    Signature

    I am who I Am!

    {{ DiscussionBoard.errors[6904284].message }}
  • Profile picture of the author Dan Grossman
    Change this:

    Code:
    RewriteRule ^mp3/(.*)$ mp3s.php?search=$1
    To this:

    Code:
    RewriteRule ^mp3/(.*)\.html$ mp3s.php?search=$1
    Then add the .html to the links on your search results page. Rewrite rules won't change the links you print out on the page, you have to do that.
    Signature
    Improvely: Built to track, test and optimize your marketing.

    {{ DiscussionBoard.errors[6905296].message }}
    • Profile picture of the author mathieu67
      Originally Posted by Dan Grossman View Post

      Change this:

      Code:
      RewriteRule ^mp3/(.*)$ mp3s.php?search=$1
      To this:

      Code:
      RewriteRule ^mp3/(.*).html$ mp3s.php?search=$1
      Then add the .html to the links on your search results page. Rewrite rules won't change the links you print out on the page, you have to do that.
      Here is the search result script. I don't know where to add the .html for the result page.

      <?php
      if( count( $mp3datas ) )
      {
      $p = array();
      foreach( $mp3datas as $data )
      {
      $p[] = $data['title'];
      }
      echo implode(', ', $p);
      }
      ?>
      </p>
      </div>
      <div class="clearfix"></div>
      </div>
      <div id="search-form">
      <h2><?php echo $site_name; ?></h2>
      <form method="post" action="<?php echo $live_site_url; ?>/search.php">
      <input type="text" name="keyword" value="" placeholder="Type song title or artist name here" />
      <button>Search</button>
      </form>
      </div>
      <div id="main-area">
      <h2>Free <?php echo ucwords( $search_display ); ?> MP3 Download</h2>
      <div id="result-area">
      <?php if( count( $mp3datas ) ) : ?>
      <?php foreach( $mp3datas as $data ) : ?>
      <div class="mp3-result">
      <strong><?php echo $data['title']; ?>.mp3</strong>
      <br />
      <?php if(!empty($data['source'])): ?>
      Hosted on: <?php echo $data['source']; ?> -
      <?php endif; ?>
      <a href="<?php echo $data['link']; ?>" target="_blank" rel="nofollow">Download Now</a>
      <br />
      <audio controls="control" preload="none" src="<?php echo $data['link']; ?>" type="audio/mp3"></audio>
      </div>
      <?php endforeach; ?>
      <div id="pagination">
      <span>Page <?php echo $page; ?> of 10</span>
      <ul>
      <?php for( $pages = 1; $pages <= 10; $pages++ ) : ?>
      <?php if( $pages == $page ) : ?>
      <li class="current"><?php echo $pages; ?></li>
      <?php else: ?>
      <?php if( $pg == 1 ) : ?>
      <li><a href="<?php echo $live_site_url; ?>/mp3/<?php echo $search; ?>"><?php echo $pages; ?></a></li>
      <?php else: ?>
      <li><a href="<?php echo $live_site_url; ?>/mp3/<?php echo $search; ?>-<?php echo $pages; ?>"><?php echo $pages; ?></a></li>
      <?php endif; ?>
      <?php endif; ?>
      <?php endfor; ?>
      </ul>
      </div>
      <?php else: ?>
      No result matching with your query.
      <?php endif; ?>
      </div>
      <div id="right-side">
      <?php if( !empty( $youtube_id ) ) : ?>
      <object width="300" height="200">
      <param name="movie" value="http://www.youtube.com/v/<?php echo $youtube_id; ?>&amp;hl=en_US&amp;fs=1"></param>
      <param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param>
      <embed src="http://www.youtube.com/v/<?php echo $youtube_id; ?>&amp;hl=en_US&amp;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="294" height="193"></embed>
      </object>
      <?php endif; ?>
      </div>
      <div class="clearfix"></div>
      </div>
      <div id="recent-search">
      <h3>Recent 200 Searches</h3>
      <ul>
      <?php if( count( $searches ) ) : ?>
      <?php foreach( $searches as $kw ) : ?>
      <li><a href="<?php echo $live_site_url; ?>/mp3/<?php echo strtolower( str_replace( ' ', '-', $kw ) ); ?>"><?php echo $kw; ?></a></li>
      <?php endforeach; ?>
      <?php endif; ?>
      </ul>
      <div class="clearfix"></div>
      </div>
      <div id="footer">
      Signature

      I am who I Am!

      {{ DiscussionBoard.errors[6905941].message }}
  • Profile picture of the author Dan Grossman
    At the very end --

    Code:
    <li><a href="<?php echo ; ?>/mp3/<?php echo strtolower( str_replace( ' ', '-',  ) ); ?>"><?php echo ; ?></a></li>
    Add the .html

    Code:
    <li><a href="<?php echo ; ?>/mp3/<?php echo strtolower( str_replace( ' ', '-',  ) ); ?>.html"><?php echo ; ?></a></li>
    Don't copy and paste because the forum is stripping some of the words from this code. Just look at where the .html was added.
    Signature
    Improvely: Built to track, test and optimize your marketing.

    {{ DiscussionBoard.errors[6906225].message }}

Trending Topics