Hi All,

Over the years I have smashed through God knows how many brick walls with .htaccess, and all I've learnt is don't even try to make it complicated as nothing is ever simple. I have therefore resorted in recent applications to using mysite.com/index.php/category/sub-category/create/ etc. and PHP to get hold of the values. But this is avoiding a problem rather than solving it.

For instance, the URL I am looking at now is: daniweb.com/web-development/php/17/contribute.

How would I go about making this in .htaccess (or moreso how has Dani done it aha).

I normally use this sort of setup:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+)/(.+)/(.+)/(.+)$ index.php?cat=$1&subcat=$2&catid=$3&task=$4 [QSA,L]

But it often plays havoc with stylesheets/PHP etc..

Is there a better way to accomplish a URL structure as complex as this? What sort of .htaccess file does DaniWeb use to support it's huge and complex URL system?

Thanks for the advice

Recommended Answers

All 5 Replies

Hi there,

DaniWeb is actually built on the CodeIgniter MVC framework, and therefore we use CodeIgniter's routing functionality.

CodeIgniter also has a single index.php file that essentially takes in the name of the class and the name of the method, and then routes to calling the appropriate function.

RewriteCond $1 !^(index\.php|js|images|favicon\.ico|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

CodeIgniter just handles it from there!

That being said, I would not recommend CodeIgniter because, although I love it and they do have an expansive community behind them, EllisLab is currently looking for new owners to maintain the project on GitHub, and there hasn't been any major updates to it in quite some time. As a result, its future looks unpredictable at this point.

Okay thanks very much, so something completely different altogether!

Ahh right, so maybe look at CakePHP or something like that for the time being?

So what happens to DaniWeb if CodeIgniter breaks down and there are no updates? :'O

Member Avatar for diafol

Code igniter did have a minor update recently, so it looks as though there is still some active dev on it. May be a bit risky though if security patches etc not released.

Codeigniter is a great framework and is very friendly. I would recommend starting off on codeigniter than cakePHP if you are just getting into php frameworks.

Codeigniter is a great framework and is very friendly. I would recommend starting off on codeigniter than cakePHP if you are just getting into php frameworks.

Thanks for the advice, but I've recently been tapping away at CakePHP, and it's working a treat (it has a pretty cool name too aha ;P).

There have been several moments of going "Really? Is that it?" when trying to get things working.

I am about to present my first CakePHP app to a client, so has been very successful.

Thanks to @Dani, @diafol and @gabrielcastillo for your replies.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.