Welcome Guest, Not a member yet? Register   Sign In
Central .htaccess file for multiple files?
#1

[eluser]mvdg27[/eluser]
Hi guys,

Not exactly a codeigniter specific question, but maybe someone has experience with this Smile

I'm trying to achieve a way to have a central .htaccess file that can be used by multiple websites. Similar to how I for example re-use a 'sorry we are offline' image across websites.

The latter I achieve through httpd.conf configuration as such:

Code:
Alias /offline.jpg /home/domains/foo/public_html/images/offline.jpg

I figured to do the same for the htaccess file, but this statement doesn't work. I assume the .htaccess file is never called like this?

Code:
Alias /.htaccess /home/domains/foo/public_html/.htaccess

Does anyone have experience on this matter? Any suggestions on how to have 1 central htaccess file being used by multiple sites?

Thanks in advance!
Michiel
#2

[eluser]WanWizard[/eluser]
Have you tried the Include directive? I use it a lot in my httpd.conf (I don't like .htaccess files on production sites, to much file system access), don't know if you can use it in a .htaccess?

Otherwise, store the orginal in a central location, and symlink to it?
#3

[eluser]bretticus[/eluser]
You cannot alias .htaccess. nor any .ht* file. Aliases are for URLs and .ht* files are blocked for a good reason. They are not meant to be seen via public access. You want to symlink as suggested. Or, even better, stick this all in an Apache config and include it in each virtualhost if you have access to the Apache config files.
#4

[eluser]mvdg27[/eluser]
Hi guys,

Thanks for the replies. I understand the point of the ht* files being blocked. Since I have access to the httpd.conf file, I want to add my htaccess directives to this file.

In doing so, I ran into some problems. I currently have this:

Code:
# alias to my central CMS (admin part)
Alias /cms /home/CMS/cms
# alias to my central CMS (website part), that handles all website requests. All requests to index.php should be directed to this file
Alias /index.php /home/CMS/website/index.php

# copy from my htaccess file with changes according to this website:
# http://www.webmasterworld.com/apache/3335621.htm
RewriteEngine on
RewriteCond $1 !^(/index\.php|/cms)
RewriteRule ^(.*)$ /index.php/$1 [L]

Now this works if I type www.mydomain.com/index.php, but if I use the domain withour index.php, or something like: www.mydomain.com/foo/bar I get:

Code:
Not Found

The requested URL /foo/bar was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

I can tell that the rewrite rules are executed, since omitting '/cms' in the statement results in an error.

Any ideas? Thanks in advance!




Theme © iAndrew 2016 - Forum software by © MyBB