Forum Moderators: phranque
AddHandler server-parsed .php
<Files ~ "^[^\.]+$">
SetHandler application/x-httpd-php
</Files>
AddHandler application/x-httpd-php .php
Note : mod_rewrite is already enabled.
php_value include_path /apache/htdocs/thesite/includes
# Allow .html .htm .asp extensions to be PHP scripted files:
AddType application/x-httpd-php .html .htm .asp
# Force Download, Not Open in Browser, for PDF, ZIP and DOC files:
AddType application/octet-stream .pdf .zip .doc
parse html for php [google.com]
Nothing fancy is needed. It does sometimes vary from host to host (with shared hosting), some need AddType and some need AddHandler.
Since <Files> does not use mod_rewrite, it is irrelevant to this case whether mod_rewrite is enabled or not.
Jim
How about pages ending with /? I don't recall seeing sites having pages both with and without a file extension, but it gets confusing because there are some new blog/cms themes that use filename endings like /foo - wouldn't those automatically put a forward slash at the end?
Correct "page" URLs do not end with "/" since a "/" at the end of a URL denotes a directory, not a page. The "index page" is an exception, because the DirectoryIndex directive can be used to map a request for the directory URL "example.com/" to the file for the example.com/index.xyz page.
You can end "page" URLs with a slash if you like but it's just not orthodox, and may cause unforeseen problems in handling by the client (e.g. search engine robots).
It pays to think about URLs, directories, and files as separate (even if slightly overlapping) concepts.
The main job of a server is to translate URLs to filepaths, independent of the filesystem structure and naming conventions used by that server's operating system.
The reason I emphasized the point about <Files> applying to filenames and not to URLs is that it is very likely that almost every URL on elvisjj's site will resolve to a filepath which includes a period and a filetype, so it's possible that that <Files> directive is not going to work as elvisjj expects it to.
Jim
I am using a dedicated server and hosting with ixwebhosting. So I am unable to access the server config files. I am only able to add anything through my Cpanel only.
I am using a script for my website where in the admin panel I have an option " Search Engine Optimized links ON / OFF - it will make .html extensions for articles and categories with their title respectively".
When turned on
"http://example.com/articles.php?art_id=1&start=1 ----> http://example.com/article/default-article-1-1.html" and
"http://example.com/category.php?cat_id=1 ----> http://example.com/category/default-category-1-1.html"
Once again I am typing the code in my .htacces file which is placed in the root directory
AddHandler server-parsed .php
<Files ~ "^[^\.]+$">
SetHandler application/x-httpd-php
</Files>
AddHandler application/x-httpd-php .php
If I placed the above said .htaccess file I am getting "500 Internal Server Error" and if I remove .htaccess file I am getting "Error 404: File Not Found".
Once again Thank you for all of you helping me.
[edited by: jdMorgan at 4:45 am (utc) on May 11, 2008]
[edit reason] example.com [/edit]
Thanks,
Elvis.
You said you cannot change your server config file, but can you "see" it? Can you get a listing of what is in there?
My only thought at the moment is that you may need to *disable* your Control Panel SE-Friendly URLs, and then replace that function in your own .htaccess file; It sounds like the SEF code generated by your control panel is buggy.
Jim
<VirtualHost *.*.*.*:*>
ServerAdmin webmaster@example.com
DocumentRoot /hsphere/local/home/user/example.com
ServerName example.com
ServerAlias www.example.com
d3888636.u78.*.examplehosting.com example.*.examplehosting.com
User user
Group user
<IfModule mod_php4.c>
AddType application/x-httpd-php .php3
AddType application/x-httpd-php-source .phps
AddType application/x-httpd-php .php
</IfModule>
<IfModule mod_php5.c>
AddType application/x-httpd-php .php3
AddType application/x-httpd-php-source .phps
AddType application/x-httpd-php .php
</IfModule>
AddHandler cgi-script .cgi
AddHandler cgi-script .pl
ScriptAlias /cgi-bin "/hsphere/local/home/user/example.com/cgi-bin"
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\""
TransferLog /hsphere/local/home/user/logs/example.com/example.com
ErrorLog /hsphere/local/home/user/logs/example.com/error_log
AddType text/html .shtml
AddHandler server-parsed .shtml
AddType text/html .html
AddHandler server-parsed .html
<DIRECTORY /hsphere/local/home/user/example.com>
OPTIONS Indexes Includes ExecCGI FollowSymLinks
AllowOverride All
</DIRECTORY>
IndexOptions FancyIndexing
</VirtualHost>
<IfDefine SSL>
<VirtualHost *.*.*.*:*>
ServerAdmin webmaster@example.com
DocumentRoot /hsphere/local/home/user/example.com
ServerName example.*.examplehosting.com
ServerAlias www.example.com
d3888636.u78.*.examplehosting.com example.com
SSLEngine on
<IfModule mod_php4.c>
AddType application/x-httpd-php .php3
AddType application/x-httpd-php-source .phps
AddType application/x-httpd-php .php
</IfModule>
<IfModule mod_php5.c>
AddType application/x-httpd-php .php3
AddType application/x-httpd-php-source .phps
AddType application/x-httpd-php .php
</IfModule>
AddHandler cgi-script .cgi
AddHandler cgi-script .pl
ScriptAlias /cgi-bin "/hsphere/local/home/user/example.com/cgi-bin"
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\""
TransferLog /hsphere/local/home/user/logs/example.com/example.com
ErrorLog /hsphere/local/home/user/logs/example.com/error_log
AddType text/html .shtml
AddHandler server-parsed .shtml
AddType text/html .html
AddHandler server-parsed .html
User user
Group user
<DIRECTORY /hsphere/local/home/user/example.com>
OPTIONS Indexes Includes ExecCGI FollowSymLinks
SSLOptions +StdEnvVars
AllowOverride All
</DIRECTORY>
SSLCertificateFile /hsphere/local/config/httpd/ssl.shared/*.examplehosting.com/server.crt
SSLCertificateKeyFile /hsphere/local/config/httpd/ssl.shared/*.examplehosting.com/server.key
IndexOptions FancyIndexing
SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
</VirtualHost>
</IfDefine>
Thanks,
Elvis.