.htaccess tutorial

htaccess Elite


SEO Friendly URLs for PHP

Search Engine Optimization using Htaccess

SEO Friendly URLs for PHP

Postby produke » 02 Oct 2006 02:38

You will need to let your Apache Server know that you want to do this.
Using the ForceType Apache Directive, you can let Apache know that the file "search", or whatever the script name will be (without .php extension), will be treated as a PHP file.

By adding the following to your httpd.conf file, you can make this happen. Just replace the directory path with your directory path to your http documnents folder.


Code: Select all
<Directory /askapache.com/httpdocs/>
<Files search>
ForceType application/x-httpd-php
</Files>
</Directory>


If you don't have access to the httpd.conf file on your web hosting server, you can create a .htaccess file with the same info, and drop it into the root of your web directory. Most web hosts will allow .htaccess files, but some won't.


You will now need to get your PHP script ready to translate the URLs that we will be sending to it.
I've used the following code on my site, though this is a much more simple version. You will need to use extensive error checking to make sure someone doesn't type in an invalid URL lacking key variables, and print errors if that happens.

Code: Select all
list($empty_variable,$php_script,$var1,$var2,$var3) =
explode("/",$REQUEST_URI);



You will finally need to make your links point to this new file "search" rather than "search.php" and have the variables appended to the URL. An example link for the previous example would be:
/search/var1/var2/var3/
User avatar
produke
 
Posts: 242
Joined: 25 Sep 2006 04:48

Re: SEO Friendly URLs for PHP

Postby olivia » 03 Dec 2008 03:18

Hi

How can I change http: to https: for my website?
olivia
 
Posts: 7
Joined: 03 Dec 2008 02:49


Return to SEO



cron