PowWeb Forums - The Perfect Community for the Perfect Host  

Register now to interact with over 11,000 members! Registered users have Posting Privileges, free access to Private Messaging, Email Notifications and more.

Go Back   PowWeb Community Forums > The PowWeb Platform > .htaccess / Scheduled Jobs
User Name
Password
Register FAQ Members List Search Today's Posts Mark Forums Read

Closed Thread
 
Thread Tools
Old 9-28-06, 06:00 PM   #1
jjny
 
Join Date: Sep 2005
Location: Duanesburg, NY
Posts: 34
Reputation: 3
.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 sites 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/".

Id 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?
jjny is offline  
Old 10-1-06, 08:39 PM   #2
produke
 
Join Date: Jul 2005
Location: USA
Posts: 119
Reputation: 41
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]
produke is offline  
Old 10-10-06, 02:48 PM   #3
produke
 
Join Date: Jul 2005
Location: USA
Posts: 119
Reputation: 41
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.
produke is offline  
Old 10-30-06, 04:45 AM   #4
produke
 
Join Date: Jul 2005
Location: USA
Posts: 119
Reputation: 41
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
produke is offline  
Closed Thread

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 09:58 AM.


Contents ©PowWeb, Inc. ~ vBulletin, Copyright 2000-2007 Jelsoft Enterprises Limited.