Archive

Posts Tagged ‘htaccess help programming’

Small .htaccess Help

October 29th, 2009 Comments off

I have a site with PHP Version 4.3.11.

I am trying to parsing php code in .htm file.

i am using this code for parsing but its not working.

AddHandler application/x-httpd-php .html .htm

Please help me.

Some .htaccess Help

April 1st, 2009 Comments off

This is a quite simple task for someone with htaccess and url rewritting skills.

I have my own very simple CMS with several modules (directory, bulleting board, faq, blog-news articles…) and I have some installations of this CMS for some sites. The structure is not always the same; in one site I have some modules active while other site may have different modules active. Now it is all dinamic url driven with GET parameters like site.com/directory.php?category=4 etc. I want to convert this urls into static ones. Of course I can handle all php link changing but I need some help with the htaccess configuration and rewriting rules.

The problem (for me, won’t be a problem for an expert ;-) is that I will not have always the same amount of parameters

I would like to have these kind of urls

www.site.com/
www.site.com/this-is-the-title-of-a-main-article-a-very-important-one/
www.site.com/contact/
www.site.com/directory/
www.site.com/directory/this-the-name-of-directory-a-category/
www.site.com/directory/addurl/
www.site.com/forum/
www.site.com/forum/this-is-a-forum-category-or-sub-forum/
www.site.com/forum/this-is-a-forum-category-or-sub-forum/this-is-a-forum-post/
www.site.com/forum/this-is-a-forum-category-or-sub-forum/this-is-a-forum-post/p2.html (second page)
www.site.com/forum/this-is-a-forum-category-or-sub-forum/this-is-a-forum-post/p3.html (third page)
www.site.com/forum/this-is-a-forum-category-or-sub-forum/this-is-a-forum-post/reply/
www.site.com/forum/this-is-a-forum-category-or-sub-forum/new-thread/
www.site.com/forum/report-violation/post24546.html
www.site.com/faq/
www.site.com/faq/this-is-a-faq-category/
www.site.com/blog/
www.site.com/blog/archive2.html (second page for older entries)
www.site.com/blog/archive3.html (second page for older entries)
www.site.com/blog/this-is-a-post-title.html
www.site.com/blog/this-is-a-category/

But you also have to note that the directory module (as well as any other module) will note be always called ‘directory’ not just because there may be non English sites, but also because it could be called ‘useful-links’ or something like that, so we will have:

www.site.com/useful-links/
www.site.com/useful-links/this-the-name-of-directory-a-category/
www.site.com/useful-links/addurl/

I don’t have any problem to receive those parameters as rewriten GET variables and find out which module is and then, depending on the module will process the rest of the parameters. Something like:

1) www.site.com/news/ -> into -> www.site.com/index.php?param1=news

2) If find out that there is no ‘main site article’ with url ‘news’

3) I find out that there is an BLOG active module in this site called ‘news’

4) There are no moe parameters, so will show the BLOG module frontpage.

5) If I receive some more parameters I will know what to do depending on order and what module I am no.

6) If there is no module or valid entry will send 301 or 404

Of course I am open to your suggestion for better ideas.

I also need of course that existing files (images, css…) not to be intercepted by rewriting and 301 redirections to non slash ending in domain or directory url (not in .html files).

Bear