Results 1 to 4 of 4

Thread: .htaccess to ADD .php file extensions

  1. #1

    Join Date
    Sep 2005
    Location
    Duanesburg, NY
    Posts
    34
    Rep Power
    0

    .htaccess to ADD .php file extensions

    This is sort of the opposite of what was discussed here:

    http://forum.powweb.com/showthread.p...ht=rewrite+php

    I used a settings option in my web site’s software (Sunshop) to make our site search friendly with Google and other search engines. For example, rather than displaying "item&id=3780&prevaction=pricelist", it displays "item/id/3780/prevaction/pricelist/".

    I’d like to use TSEP search engine to index my site for searching. It requires file extensions before it will index the contents of a page. I need it to index the contents of my web site which displays listing details such as Title, Author, Publisher, etc. from within links such as the one shown above.

    I read that someone used mod_rewrite to make their site search friendly. Rather than displaying "item.php?id=5," for example, they did "item/5“. When using the TSEP search engine to index the site, they ran into a problem because this meant that each page was linked to without a file extension, and thus was not indexed.

    In order to fix this, they changed their .htaccess file's mod_rewrite entries to the format of "item/5.php". Their site now displays as individual pages for each database entry which they say makes Google happy, and it also continues to have a file extension, which makes TSEP happy.


    Can someone suggest some code I could enter in a .htaccess file for upload to the server so that my files like the above get a .php extension added to them? Also, information on where to place this .htaccess file relative to the location of htdocs/tsep/ and the files within the tsep folder?

  2. #2

    Join Date
    Jul 2005
    Location
    USA
    Posts
    119
    Rep Power
    12
    I am using a mod like this for the htaccess forum at askApache.com, where instead of
    http://www.askapache.com/htaccess/index.php the url is http://www.askapache.com/htaccess/htaccess-vc1.html

    and for http://www.askapache.com/htaccess/viewtopic.php?t=5 its
    http://www.askapache.com/htaccess/ca...pires-vt5.html


    This rewrites internally all .html files to .php
    Code:
    RewriteEngine On
    RewriteBase /
    RewriteRule (.*)\.html$ $1.php [L,T=application/x-httpd-php]
    Forcing any files to be a certain type of file:
    Code:
    <Files index.php>
     ForceType application/x-httpd-php 
    </Files>
    Name php files .html
    Code:
    AddType application/x-httpd-php .html
    If using phpbb:

    Remove SID for guests
    phpBB SEO mod rewrites
    Gives you an htaccess like this-
    Code:
    RewriteEngine On
    RewriteBase /
    
    RewriteRule ^s/(.*)\.pl$ /cgi-bin/$1.php [L]
    
    
    # FORUMS PAGES
    ########################
    # FORUM PROTECTION RULE
    RewriteRule ^htaccess/.+/([^/]+\.html)$ /htaccess/index.php [R=301,L]
    # CATEGORIES
    RewriteRule ^htaccess/.+-vc([0-9]+)\.html$ /htaccess/index.php?c=$1 [QSA,L]
    # PAGINATED FORUM
    RewriteRule ^htaccess/.+-vf([0-9]+)-([0-9]+)\.html$ /htaccess/viewforum.php?f=$1&start=$2 [QSA,L]
    # FORUM
    RewriteRule ^htaccess/.+-vf([0-9]+)\.html$ /htaccess/viewforum.php?f=$1 [QSA,L]
    # PAGINATED TOPIC
    RewriteRule ^htaccess/.+-vt([0-9]+)-([0-9]+)\.html$ /htaccess/viewtopic.php?t=$1&start=$2 [QSA,L]
    # TOPIC
    RewriteRule ^htaccess/.+-vt([0-9]+)\.html$ /htaccess/viewtopic.php?t=$1 [QSA,L]
    # POST
    RewriteRule ^htaccess/post([0-9]+)\.html$ /htaccess/viewtopic.php?p=$1 [QSA,L]
    #PROFILES
    RewriteRule ^htaccess/member([0-9]+)\.html$ /htaccess/profile.php?mode=viewprofile&u=$1 [QSA,L]

  3. #3

    Join Date
    Jul 2005
    Location
    USA
    Posts
    119
    Rep Power
    12
    Quote Originally Posted by keyplyr View Post
    Actually this parses .html files for php application, it doesn't change the name of .php files to .html.
    Yes, I was assuming that he would be renaming the php files to html, at least, for that particular solution. I think I provided about 4 different ways to do this.

    They would still be php files, but the extension would be .html, this is basically required if you want any SEO.

  4. #4

    Join Date
    Jul 2005
    Location
    USA
    Posts
    119
    Rep Power
    12
    Ooops, should read like this:

    I am using a mod like this for the htaccess forum at htaccesselite.com, where instead of
    http://www.htaccesselite.com/htaccess/index.php the url is http://www.htaccesselite.com/htaccess/htaccess-vc1.html

    and for http://www.htaccesselite.com/htaccess/viewtopic.php?t=5 its
    http://www.htaccesselite.com/htacces...pires-vt5.html


    This rewrites internally all .html files to .php
    Code:
    RewriteEngine On
    RewriteBase /
    RewriteRule (.*)\.html$ $1.php [L,T=application/x-httpd-php]
    Forcing any files to be a certain type of file:
    Code:
    <Files index.php>
     ForceType application/x-httpd-php 
    </Files>
    Name php files .html
    Code:
    AddType application/x-httpd-php .html
    If using phpbb:

    Remove SID for guests
    phpBB SEO mod rewrites
    Gives you an htaccess like this-
    Code:
    RewriteEngine On
    RewriteBase /
    
    RewriteRule ^s/(.*)\.pl$ /cgi-bin/$1.php [L]
    
    
    # FORUMS PAGES
    ########################
    # FORUM PROTECTION RULE
    RewriteRule ^htaccess/.+/([^/]+\.html)$ /htaccess/index.php [R=301,L]
    # CATEGORIES
    RewriteRule ^htaccess/.+-vc([0-9]+)\.html$ /htaccess/index.php?c=$1 [QSA,L]
    # PAGINATED FORUM
    RewriteRule ^htaccess/.+-vf([0-9]+)-([0-9]+)\.html$ /htaccess/viewforum.php?f=$1&start=$2 [QSA,L]
    # FORUM
    RewriteRule ^htaccess/.+-vf([0-9]+)\.html$ /htaccess/viewforum.php?f=$1 [QSA,L]
    # PAGINATED TOPIC
    RewriteRule ^htaccess/.+-vt([0-9]+)-([0-9]+)\.html$ /htaccess/viewtopic.php?t=$1&start=$2 [QSA,L]
    # TOPIC
    RewriteRule ^htaccess/.+-vt([0-9]+)\.html$ /htaccess/viewtopic.php?t=$1 [QSA,L]
    # POST
    RewriteRule ^htaccess/post([0-9]+)\.html$ /htaccess/viewtopic.php?p=$1 [QSA,L]
    #PROFILES
    RewriteRule ^htaccess/member([0-9]+)\.html$ /htaccess/profile.php?mode=viewprofile&u=$1 [QSA,L]
    More available in the SEO forum
    Last edited by produke; 10-30-06 at 04:46 AM. Reason: fix URL= syntax

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •