I am designing a CMS that uses a slightly different approach to SEF URL,s than most by what I have seen.
Basically, instead of converting the SEF URL into a URL with an appended query string, my CMS will be using the SEF URL as is.
I seem to be having some problems designing a good set of mod rewrite rules for it.I can generally write a single rule and get it working just fine, its when I start combining them that things start going wrong.
I know how to describe these rules, so i,ll do that and maybe someone can help with coding them and help putting them in order.
- Code: Select all
RewriteCond %{QUERY_STRING} !^$
RewriteRule (.*) $1? [R=301]- Code: Select all
RewriteCond ${REQUEST_FILENAME} !-f
RewriteCond ${REQUEST_FILENAME} !-d
RewriteRule .* index.php
1 -- If there is a query string, it should be removed completely and visibly redirected.
2 -- If the request is in the correct format i.e ...
/index
/index/
/admin/modules
/admin/modules/
/news
/news/
/news/edit/123
/news/edit/123/
then am I correct in thinking that if the directories/files dont exist that the following should work ...
3 -- The directory structure of the cms is as follows ...
/classes/
/components/
/modules/
/templates/
/images/
.htaccess
stylesheet.css
index.php
config.php
All site requests will be going through index.php as this is the controller, if any requests are made for the files in the other directories, then this isnt allowed, and should be redirected to /index so they get the home page.
I havnt got a clue how to do this, but I think I may need a .htaccess file in each directory, if someone could confirm this is it would be appreciated.
4 -- For a page request, there will also be additional requests for other files, like .css, .ico, .gif etc, etc. Am I correct in thinking that these will have a referrer value correspondong to my site, therefore making it possible to create a rule that would allow these files to be served as is and not rediredted to index.php.
5 -- Lastly, I would like a rule that strips off any file extensions like .php, .htm, .html and .asp, but everything I have tried results in an endless loop because i,m redirecting to index.php
Oh, one last question, i,m designing this CMS in PHP, will any of these rules affect php including files?
Errrr, thats about it, as you can see its getting complicated, and help anyone can give would be appreciated.
Thankyou