PHP .htaccess issue, specific/dynamic keywords

Posted by Kunal on Stack Overflow See other posts from Stack Overflow or by Kunal
Published on 2010-04-27T13:29:59Z Indexed on 2010/04/27 13:53 UTC
Read the original article Hit count: 294

Filed under:
|

Here goes my .htaccess file's content.

Options +FollowSymLinks
RewriteEngine On 
RewriteRule ^online-products$ products.php?type=online
RewriteRule ^land-products$ products.php?type=land
RewriteRule ^payment-methods$ payment-methods.php
RewriteRule ^withdrawal-methods$ withdrawal-methods.php
RewriteRule ^deposit-methods$ deposit-methods.php
RewriteRule ^product-bonuses$ product-bonuses.php
RewriteRule ^law-and-regulations$ law-and-regulations.php
RewriteRule ^product-news$ product-news.php
RewriteRule ^product-games$ product-games.php
RewriteRule ^no-products$ no-products.php
RewriteRule ^page-not-found$ notfound.php
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^casinos/(.*)$ product.php?id=$1
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ cms.php?link=$1
ErrorDocument 404 /notfound.php

What I am trying to achive here is that the first set of rules apply to some specific keywords which should redirect to specific hard coded pages. But anything else parat from those keywords should redirect to cms.php as a parameter as you can see.

But the problem is that every keyword is getting redirected to cms.php. Whereas I want any other keyword apart from which are already hard coded in .htaccess file should go cms.php. Not just every keyword.

Example:

www.sitename.com/online-products -> www.sitename.com/products.php?type=online
www.sitename.com/about-the-website -> www.sitename.com/cms.php?id=about-the-website
www.sitename.com/product-news -> www.sitename.com/product-news.php

Also another issue I am facing is I can not use any keyword with space. Like "online-products" is fine, but I can't use "online products".

Please help me out with your expert knowledge. Many thanks in advance for your kind help. Appreciate it.

© Stack Overflow or respective owner

Related posts about php

Related posts about .htaccess