How big can your htaccess be?

My website has around 500 pages that used to be html. Because the host decided to change the way php functioned, I could no longer parse html as php. The problem is that almost all of the pages in the website have php includes. If I can not parse html as php, my headers, footer, and side bar are not shown.

My solution after trying to resolve it other ways was to just upload copies of all of the html files with the extension changed to .php and do a global redirect in my htaccess.

This solved the major problem, but created a couple of minor ones.

Some of the pages in the site that I do not want redirected are being redirected {a couple of forum pages and the 404.shtml error page}.

How do you guys think I could solve this? My current idea is to eliminate the global redirect and upload an htaccess with individual redirects for all of the 500 pages in the website. I can probably do that in notepad in 10 minutes. My concern is that the browsers or the server might not like a 500 line htaccess file.

Opinions?

It’s probably easier to create an exception for the global redirect to spell all the redirects out manually.

Eg.


RewriteEngine On

# if the request is not for /forum or /someotherpath ...
RewriteCond %{REQUEST_URI} ^/forum [OR]
RewriteCond %{REQUEST_URI} ^/someotherpath
# ... redirect
# <insert your global redirect rule here>

Does that help or did I misunderstand your question?

Yes that is actually what I want to acomplish, would you mind helping with the actual code that I need to insert prior to the global redirect rule.

There is one directory that I do not want affected by the global redirect, and one file that I do not want affected in the root public directory

They are:


http://www.loanuniverse.com/forums/
http://www.loanuniverse.com/404.shtml

Thanks a lot in advance to anybody that can help

Well, that’s pretty much what I put in my last post, but modified slightly:


RewriteEngine On

# if the request does not start with /forums/ and the request is not for /404.shtml ...
RewriteCond %{REQUEST_URI} ^/forums/ [OR]
RewriteCond %{REQUEST_URI} ^/404\\.shtml$
# ... redirect
# <insert your global redirect rule here>

:slight_smile:

Out of curiosity, what is your global rewrite rule?

Thank you very much.

Now do not laugh but I know nothing of rewrite rules. In fact, I was never any good with anything related with site hosting, servers or even design. Lets just say that I wrote every page using tables.

lu,

First, I would merely add the AddType application/x-httpd-php .php statement to the .htaccess (which is allowed per http://httpd.apache.org/docs/2.2/mod/mod_mime.html#addtype). I can’t see how your host could disable that.

Second, a global rename of your files is possible via a shell - but this would be ugly. It would also require a simple substitution RewriteRule to change the .html to .php and could be invisible or 301’s to the world.

Third, INDIVIDUAL REDIRECTS? Horrors! The first thing to learn about .htaccess is NOT to use it unless absolutely necessary. While it is necessary in your case (until you ditch that host and get a good one), creating a huge file which must be read and parsed multiple times for every file request is an abuse of the server (and even your bad host should give you the boot for that). Option two above is far better than a long list of Redirect statements but Option 1 will do the job for you very simply.

Rémon,

You forgot the ! in both the directory and file RewriteCond statements (which then should be ANDed) as you only want to redirect is NOT A AND NOT B.

Regards,

DK