I’ve got a CAKEPHP app which has the following rewrite rules in the .htaccess in the webroot folder.
<IfModule mod_rewrite.c>
RewriteEngine On RewriteCond %{HTTP_HOST} !^domain.com$ [NC]
RewriteRule ^(.*)$ domain.com/$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
I have never worked with CakePHP before and am a PHP beginner, and have written a standalone php script which I have in a folder named ‘products’ in the webroot folder. My index page in this folder takes in an id and then retrieves the product name and description from the DB. (There are hundreds of products)
So: http://www.domain.com/products/index.php?id=1
I wish to include a rule where by the URL should look like:
http://www.domain.com/products/the-flux-capacitor
Please can someone tell me how I can achieve this without destroying any of the CakePHP rewrites?
If you use the following URL structure
www.domain.com/products/the-flux-capacitoryou still need a way to map every product name, which must be unique, to its id, and it will be a larger effort.However, if you use a slightly modified URL structure,
www.domain.com/products/the-flux-capacitor/id(even Amazon does this), then it is much easier and the following .htaccess code will do the rewrite for you