Can't include JS and CSS(htaccess problem)

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Can't include JS and CSS(htaccess problem)

Postby mgala » 04. January 2008 07:23

Hello there,

So I've installed Apache, and finally got it setup so htaccess would work too.
Now it just won't include stylesheets and javascript files :-(

(htaccess)
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-F
RewriteRule ^(.*)$ index.php?index=$1&%{QUERY_STRING} [QSA,L]

Instead it includes index.php because the script tells it to redirect to index.php no matter what.

What I don't understand is that the exact same script works on all the webhosts I've tried it out on.

So what do I do? How do I set it up, so it allows me to include stylesheets, images, javascript etc.????


Thanks up front!
mgala
 
Posts: 9
Joined: 04. January 2008 07:17

Postby Izzy » 04. January 2008 07:31

You did uncomment the mod_rewrite module in the httpd.conf file?
xampp\apache\conf\httpd.conf

#LoadModule rewrite_module modules/mod_rewrite.so
to
LoadModule rewrite_module modules/mod_rewrite.so

Save the file after editing then restart Apache to get the edits recognized - always make a backup of conf and ini files before editing.
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Postby mgala » 04. January 2008 07:40

Hi Izzy,

Yea, that's exactly what I've done to make .htaccess work =/

In fact that's the only thing I've done, should I check/uncheck/change anyting else, or?
mgala
 
Posts: 9
Joined: 04. January 2008 07:17

Postby Izzy » 04. January 2008 07:42

That depends on the missing details in your post about the directory where the .htaccess file is located.
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Postby mgala » 04. January 2008 07:45

It's located in the main directory :-)
mgala
 
Posts: 9
Joined: 04. January 2008 07:17

Postby Izzy » 04. January 2008 07:51

mgala wrote:It's located in the main directory :-)

I don't see a main directory in my XAMPP installation.
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Postby mgala » 04. January 2008 07:54

No -_-

The .htaccess file is located in the main directory of my website.

MYSITE/folders/
MYSITE/folderhere/
MYSITE/index.php
MYSITE/.htaccess
mgala
 
Posts: 9
Joined: 04. January 2008 07:17

Postby Izzy » 04. January 2008 07:56

...and that MYSITE directory is located where?
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Postby mgala » 04. January 2008 08:02

In htdocs :)
C:\xampp\htdocs\mysite\.htaccess

And I'm accessing the site through: http://localhost/mysite/
mgala
 
Posts: 9
Joined: 04. January 2008 07:17

Postby Izzy » 04. January 2008 08:12

http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html

Have a look at the section which relates to the RewriteBase directive and see if it applies.

Also, a bit old, but I posted a bit of a mod_rewrite Tutorial that may help as a reference.
http://community.apachefriends.org/f/viewtopic.php?t=20957

There have been quite a few mod_rewrite posts in the past.

The reason I asked for the location is to see if you required the Allow directive setting for your particular location - always saves time if you include as many details as possible, even if you think they may not be important.
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride All


This is set for the server's DocumentRoot htdocs in the httpd.conf file and for all it's sub directories unless it has been changed - it won't hurt to include it in the .htaccess file just to make sure.
http://httpd.apache.org/docs/2.2/mod/directives.html

BTW In Apache MYSITE is a different directory to mysite.

http://httpd.apache.org/docs/2.2/howto/htaccess.html
http://wiki.apache.org/httpd/Rewrite
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Postby mgala » 04. January 2008 08:22

Hi again,

To be honest I'm not really sure what to look for : )

(http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html & http://community.apachefriends.org/f/viewtopic.php?t=20957 )
The script itself works fine, used it before and works fine on several webhosts.

(http://httpd.apache.org/docs/2.2/mod/directives.html)
I have no idea what to look for on that list : o


I really appreciate your help, but I think you've misunderstood my problem ^^

There's nothing wrong with the .htaccess files content or location.
I have either forgot to setup something, or there's something wrong with the XAMPP(doubt it) =/
mgala
 
Posts: 9
Joined: 04. January 2008 07:17

Postby Izzy » 04. January 2008 08:34

XAMPP works most of the time "Out of the Box" and you have changed the only configuration to get mod_rewrite working in the htdocs directory.

The rest is up to you and how the mod_rewrite entry and the .htaccess file are written - and just because it works on a production server doesn't mean it will work on every server - different versions and OS etc. can affect many things.

Worth looking in the xampp\apache\logs\error.log file for any possible clues - but you would have done that already?

You also now have much reading to help you further understand the subject and what you are trying to do.
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Postby mgala » 04. January 2008 08:50

Yea already checked the error log, and no errors occur unless I have htaccess turn off.

I didn't know it could be written in different ways =/

So how would you write a script that displays:
http://site.com/index.php?index=one&two=three

Like this:
http://site.com/one?two=three

Cause through the eyes of a htaccess-newbie(my eyes) there is no other way to write it than the one I'm using at the moment : )

I don't wanna be a pain in the ass, but I really don't have time to go through a whole manual right now, I just need to get it fixed quickly.

It really has nothing to do with laziness because I read pages of documentation everyday so I know what the heck I'm doing, but in this case I just don't have the time : (

Anyway..

You think you could put together a quick solution? I would be very grateful : )
mgala
 
Posts: 9
Joined: 04. January 2008 07:17

Postby Izzy » 04. January 2008 08:58

Try this but no guarantee
Code: Select all
RewriteEngine On
RewriteBase /mysite/
RewriteCond %{REQUEST_FILENAME} !-F
RewriteRule ^(.*)$ index.php?index=$1&%{QUERY_STRING} [QSA,L]


You may have to experiment with the RewriteBase path.
RewriteBase /
RewriteBase /mysite
etc.
Get the idea?
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Postby mgala » 04. January 2008 09:12

Tried every possible combination, no effect : (
mgala
 
Posts: 9
Joined: 04. January 2008 07:17

Next

Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 49 guests