views:

56

answers:

2

In my htaccess i have

RewriteRule ^([^/]+)/?$ cms.php?seotitle=$1 [L]

The idea is that index.html will load fine and then anything requested at domain.com/anythinghere.html will use the rule of grabbing the file from cms.php.

However its not working - any clues? Really need this sorted asap.

+1  A: 

Try this one:

RewriteCond %{REQUEST_URI} !(index.html)
RewriteRule ^([^/]+)/?$ cms.php?seotitle=$1 [L]

Another way is to use the -f or -d flags, which mean existing file or directory.

RewriteCond %{REQUEST_URI} !-d
RewriteCond %{REQUEST_URI} !-f
RewriteRule ^([^/]+)/?$ cms.php?seotitle=$1 [L]

When you use this, any existing file or directory will not be rewritten. This is useful, especially for css or js files.

davethegr8
It doesnt work still. It loads my page template but will not load the content. if i type in the browser mydomain.com/cms.php?seotitle=something.html then it works fine but the rewrite still doesnt work.
seanprice
Should it be index.php instead of .html? The key part is the RewriteCond.If that still doesn't work, change the rewriterule to something like test.php that just does print_R($_GET)
davethegr8
I did as you said with test.php and got the following when trying to request mydomain.com/about.html<code>Array ( [seotitle] => test.php )</code>
seanprice
that new code with the flags prevents even the index.php from loading and still doesnt fix the issue with the cms.php
seanprice
A: 

Try this rule:

RewriteCond $1 !^(cms\.php|index\.html)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/?$ cms.php?seotitle=$1 [L]
Gumbo
boom - it worked - excellent thanks!
seanprice