/    Sign up×
Community /Pin to ProfileBookmark

PHP CMS Framework Problem….

Hello,

I’m working on developing a PHP MySQL CMS framework that I can use for websites. It’s been going well so far until I hit a snag using AJAX yesterday.

Basically, I have an template.php file that does all the work. I use .htaccess to always redirect to the template file. The template checks to see if the page exists, then includes that page or an error page inside of the html head and footer, I think this is pretty standard.

here is my .htaccess file:

[CODE]
ErrorDocument 404 /pages/error_page.php
RewriteEngine on
RewriteBase /

RewriteRule ^(.*)$ template.php [nc]
[/CODE]

The problem is when I am calling CSS, JS, or AJAX files. It puts the header and footer content around the CSS file, so I get an error. Is there a way that I can say in the .htacess that if the URL is [url]http://www.mysite.com/contact_us.php[/url], use template.php but if it is [url]http://www.mysite.com/ajax/getAddress.php[/url], don’t use the template? I’ve been working on the .htaccess file for 2 days and I can’t get it to work. I can make it work if I change the content URLS to like mysite.com/template1/contact_us.php, but I don’t want the URLs to be developed like this.

Any suggestions would be helpful.

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@jasonahouleNov 27.2007 — You can do your check on any character that would be included in your file name.

RewriteRule ^([Aa-Zz0-9]*).(.*)$ template.php [nc]

This way you include all alpha numeric characters the period and nothing else. It shouldn't work if there is a path separator in there. I must admit that I have not tested this.
Copy linkTweet thisAlerts:
@jesseainskeepauthorNov 27.2007 — I'm not sure if this would work, let me clarify a little more.

template.php does this: <html><head></head><body>include file called in URL</body></html>

I want template.php file to be used every time a page is called in the root directory. Examples: mysite.com/contact_us.php or mysite.com/products.php

I don't want template.php to be called if the file is mysite.com/styles/defaults.css or mysite.com/images/frontpic.jpg or mysite.com/json/getaddress.php

With the .htaccess file I have, it calls template.php everytime. So when I like the stylesheet, and view the source of the stylesheet, it appends the <html><head> ect to the stylesheet.

A quick way around this was to create a new .htaccess within the styles directory that said:

[CODE]
RewriteEngine off
[/CODE]


But, when using AJAX to call a PHP file, it ignores the .htaccess file in that directory and inherits the parent .htaccess file.

I'm wanting a way in my parent .htaccess file to say ignore template.php if the file is in directory styles, images, or json.
×

Success!

Help @jesseainskeep spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...