tags:

views:

37

answers:

2

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.

A: 

You can solve the first part by adding [L] to the end of your rules, e.g.:

RewriteRule ^page-not-found$ notfound.php [L]

This should prevent any subsequent rules from being run. See: http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#rewriterule

If you must have a space in the URL you should be able to do this:

RewriteRule ^online\sproducts$ products.php?type=online [L]
Tom Haigh
Lemme try this and will get back. Thanks a tonne :)
Kunal
The space issue is working fine, thanks a lot :)But the rule is still not working :( I am posting the new updated code as a new answer below, please refer to that.
Kunal
got it working now :)
Kunal
A: 

Here is the updated code:

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