httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lists.sebast...@abwesend.de
Subject [users@httpd] Modular .htaccess files
Date Mon, 15 Aug 2011 10:34:44 GMT
Hi,

I have an idea on .htaccess files or rather a tiny feature request. :) Before I post it to
the bugzilla system as a "real" feature request, I wanted to put the idea up for discussion.
;) By the way, Apache is a really great piece of software and I like to use it! ;) 

But first of all one more thing: Yes, I know that .htaccess is only the second best alternative
and people should rather use httpd.conf BUT in my opinion there are reasons "pro" .htaccess
(for example, if you can't change the server configuration). 

IDEA: It was a great thing, if one could cascade/include .htaccess files (Include .htaccess-2)
or make Apache parse more than one .htaccess file per directory (.htaccess-botrestriction,
.htaccess-legacyurlrewrite, ...). A modular approach for .htaccess files could provide an
increased flexibility and an improved manageability.


Scenario 1:
---
You have big .htaccess files containing anti-bot ip restrictions, legacy URL rewrite rules,
SEO URL rewrite rules etc.
- Restrict certain IP ranges from accessing your folders/forum/blog/whatever. This can be
done through .htaccess.
- "Cool URIs don't change" [1]. We all know that. But sometimes you have to change your directory
structure (e.g. new CMS software) and then it's good to keep the old addresses working through
"HTTP/301 Moved Permanently" forwardings. This can be done through .htaccess.
- Everybody seems to love SEO URLs. Users and decision makers demand them, although there
are people who say there's no use in using them. So if you want to meet the demand, you need
to offer these /products/my-product-123.html addresses. This can be done through .htaccess.
If one puts all these things into one big file, it can become confusing and hard to maintain.
It would be easier to keep track of these things if you could do something like this:

[Content of .htaccess]
# Some common directives ...
# ...
# Include more .htaccess files:
Include .htaccess-botrestrictions
Include .htaccess-keepalivelegacyurls
Include .htaccess-fancyseourls


Scenario 2:
---
You develop some web applications locally (local LAMP server/developer machine) and often
deploy the changes made to your productive environment (virtual server on the net, cloud hosting,
dedicated server, ...). I have a few of these projects and the project files are the same
online and offline, apart from one config.inc.php (database configuration, paths etc.) and
the .htaccess file. I exclude the server-specific config.inc.php from synchronizing. So I
can just upload all the other files without problems (WinSCP or sth. like this). ALL the other
files? No, there's one file that needs to be merged manually!! :D It's the .htaccess file.
I can't just overwrite the version on the production server with my local file version because
there are few lines that need to be different. So I have to edit this file manually and be
very very careful not to put in the local (==wrong) paths on the server.
It would make things much easier, if you could keep more than one .htaccess file. I could
use one .htaccess-serverspecific, which could be excluded from sync, and one .htaccess-common,
which could be overwritten (local dev machine ->> web server) airly.


These are only two ideas on how these feature could be useful to users.


My 2 ideas on how to do that:
---
1) Allow Include in context .htaccess. See [2].
2) Allow Apache to read more than one .htaccess files per directory (e.g. all files with a
certain prefix, for example .htaccess-([a-z]+) )


Do you think there might be a chance to suggest this topic to the developers? At least *I*
would like to have these feature[s] in Apache httpd. :)

Thanks a lot!

Regards,
Sebastian


Web links:
[1] http://www.w3.org/Provider/Style/URI.html
[2] http://httpd.apache.org/docs/2.0/mod/core.html#include


-- 
NEU: FreePhone - 0ct/min Handyspartarif mit Geld-zurück-Garantie!		
Jetzt informieren: http://www.gmx.net/de/go/freephone

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message