Mod Rewrite Issue?

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

Mod Rewrite Issue?

Postby vaciliy » 02. May 2011 12:31

Hi,
My first post, so please be patient. I posted this message in the wrong forum first (German).

I am using Win 7. I downloaded XAMPP 1.7.1. I had to change the http://localhost/ to http://localhost:8080/ as port 80 was already busy. In httpd.conf I changed AllowOverride to All.

I run a local website (php 4.2 and MySQL). The root directory of the website (located in E:\xampp\htdocs\test) contains an htaccess file.

I checked the php info to see that mod_rewrite is loaded. The htaccess file is also working correctly and is being picked up (I tried to enter nonsense text in the htaccess file and got a server error after that which confirms the htaccess is fine).

The website's home page loads fine, but it does not seem to pick up css or javascript files. The home page text and images having a direct url are shown, but any css styling isn't applied. In addition, any links to other pages just take me to http://localhost/xampp/.

I checked the error logs and they show this error (there are a lot of lines like this):

[Sun May 01 22:26:57 2011] [error] [client 127.0.0.1] File does not exist: E:/xampp/htdocs/scripts, referer: http://localhost:8080/test/.

The htaccess file is as follows (this file works great on the remove server):

RewriteEngine On

RewriteBase /

#Options +FollowSymLinks

<FilesMatch ".(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Expires "Thu, 15 Apr 2015 20:00:00 GMT"
Header set Cache-Control "max-age=172800, public, must-revalidate"
</FilesMatch>

Header unset ETag
FileETag None

<IfModule mod_deflate.c>
SetOutputFilter DEFLATE
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png|rar|zip|pdf)$ no-gzip dont-vary
<IfModule mod_headers.c>
Header append Vary User-Agent
</IfModule>
</IfModule>

<IfModule mod_expires.c>

# enable expirations
ExpiresActive On
ExpiresByType image/gif "access plus 7 days"
ExpiresByType image/jpeg "access plus 7 days"
ExpiresByType text/css "access plus 7 days"
ExpiresByType application/x-shockwave-flash "access plus 7 days"
ExpiresByType application/javascript "access plus 7 days"
ExpiresByType text/javascript "access plus 7 days"
ExpiresByType image/png "access plus 7 days"
<FilesMatch "\.(ico|gif|jpg|jpeg|png|flv|pdf)$">
Header append Cache-Control "public"
</FilesMatch>
<FilesMatch "\.(js|css|swf)$">
ExpiresDefault "access plus 7 days"
Header append Cache-Control "public"
</FilesMatch>
</IfModule>

AddEncoding gzip .gz
RewriteCond %{HTTP:Accept-encoding} gzip
RewriteCond %{HTTP_USER_AGENT} !Safari
RewriteCond %{REQUEST_FILENAME}.gz -f
RewriteRule ^(.*)$ $1.gz [QSA,L]

#RewriteRule favicon.ico images/favicon.ico [NC,L]
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
#php_flag magic_quotes_gpc Off

Any ideas of why this is happening?

Thanks
Vaciliy
vaciliy
 
Posts: 11
Joined: 02. May 2011 03:37

Re: Mod Rewrite Issue?

Postby vaciliy » 03. May 2011 00:49

Anybody could assist with this? Thanks!
vaciliy
 
Posts: 11
Joined: 02. May 2011 03:37

Re: Mod Rewrite Issue?

Postby Nobbie » 03. May 2011 10:58

Which application did you install in your DocumentRoot?
Nobbie
 
Posts: 8779
Joined: 09. March 2008 13:04

Re: Mod Rewrite Issue?

Postby vaciliy » 03. May 2011 13:12

It's a website based on Zend Framework.
vaciliy
 
Posts: 11
Joined: 02. May 2011 03:37

Re: Mod Rewrite Issue?

Postby Nobbie » 03. May 2011 13:44

And is called? Name? How did you install it?
Nobbie
 
Posts: 8779
Joined: 09. March 2008 13:04

Re: Mod Rewrite Issue?

Postby vaciliy » 03. May 2011 14:33

It is a custom created website. It does not use any crm like drupal if that is what you mean?

The website uses PHP, MySQL, JavaScript.

There was no installation. I just moved all files from the remote server to the test folder within htdocs folder in xampp, then changed configuration to point to local MySQL database and changed path to localhost.
vaciliy
 
Posts: 11
Joined: 02. May 2011 03:37

Re: Mod Rewrite Issue?

Postby Nobbie » 03. May 2011 22:59

vaciliy wrote:It is a custom created website.


Ok.

So why do you ask here, if its custom created? As you cannot provide any useful information, you should ask the "creator" of the site. This issue is NOT a Xampp or an Apache issue.
Nobbie
 
Posts: 8779
Joined: 09. March 2008 13:04

Re: Mod Rewrite Issue?

Postby vaciliy » 03. May 2011 23:15

I asked because I am using xampp. The website works great on the remote server, but not locally. It is not a problem with the website. It is probably a matter of adjusting xampp or htaccess settings. That is why I posted htaccess settings currently in place. I hoped there may be somebody who could give advice on what to do to fix my issue.

From you latest response, what kind of into are out looking for? Maybe I missed it in my answers, but I thought I answered questions which were asked. Is there anything else that may help answer my question.
vaciliy
 
Posts: 11
Joined: 02. May 2011 03:37

Re: Mod Rewrite Issue?

Postby Nobbie » 04. May 2011 11:12

vaciliy wrote:From you latest response, what kind of into are out looking for? Maybe I missed it in my answers, but I thought I answered questions which were asked. Is there anything else that may help answer my question.


I am pretty sure, that the "software" you use, tries to evaluate the setting of "ServerName" either from the PHP Environment ($_SERVER) or from any kind of installation setup (like wordpress, joomla etc. do - all these tools ask for a servername at installation time). The PHP Environment (or any other script language) evaluates the "ServerName" Configuration Value from your Apache Configuration (either ServerName in global section or in any VirtualHost).

The ServerName obviously does not contain any information about the port - it is simply called "localhost" in your "system" (either httpd.conf or any config file of your script). This is ok for Port 80, as "localhost" yields to "localhost:80" (Port 80 is the default HTTP Port if it is omitted in the URL). But you changed the Port from 80 to 8080 - and the "software" obviously builds the URLs for CSS and JavaScript (and for images too, possibly) with the help of this ServerName - therefore

a) you have to change the ServerName in httpd.conf from "localhost" to "localhost:8080"

OR

b) you have to change the software (therefore I said, generally it is a software error - because it ignores the value of the Port), that it does not only evaluate the ServerName, but as well the HTTP Port (it is called $_SERVER["SERVER_PORT"] in PHP) for building the URLs of CSS etc.

OR

c) you have to change any kind of config file of your software and change "localhost" to "localhost:8080"
Nobbie
 
Posts: 8779
Joined: 09. March 2008 13:04

Re: Mod Rewrite Issue?

Postby vaciliy » 04. May 2011 12:29

Thanks Nobbie, I will try your suggestions to see if I can fix this.
vaciliy
 
Posts: 11
Joined: 02. May 2011 03:37

Re: Mod Rewrite Issue?

Postby vaciliy » 06. May 2011 02:55

I played with xampp a little more and finally decided to remove the software which blocked port 80 (sql reporting services). I then changed the reference from localhost:8080 to localhost:80 in the apache config file.

Unfortunately, that didn't fix the issue.

For example, the generated home page would show the following in the header:

Code: Select all
<link href="http://localhost/test/styles/style.css" rel="STYLESHEET" type="text/css" />
<script type="text/javascript" src="http://localhost/test/scripts/jquery.json-2.2.min.js"></script>


The links point exactly to the location on my hard-drive where the styles.css and jquery.js are located.

At the same time a link to an image works because the image shows up:

Code: Select all
<div class="logo"><img src="http://localhost/test/images/logo.png" width="356" height="77" /></div>


The config file for the website lists the following values which are applicable to this issue:

Code: Select all
<siteHost>http://localhost/test/</siteHost>
<database>mysql://root:@localhost/prod</database>


Not sure what to try next. Any ideas?

Thanks
Vaciliy
vaciliy
 
Posts: 11
Joined: 02. May 2011 03:37

Re: Mod Rewrite Issue?

Postby Sharley » 06. May 2011 03:13

Code: Select all
<siteHost>http://localhost/test/</siteHost>
Try removing the test trailing slash and see if it helps - only a guess based on the way a virtualhost in Apache works (no trailing directory slash), as most other code pasted looks fine to my old eyes. :)
Code: Select all
<siteHost>http://localhost/test</siteHost>

Also won't hurt to clear your browser's cache often when developing at localhost level to help prevent a cached page instead of a new edited page from being shown in the browser.
Last edited by Sharley on 06. May 2011 03:35, edited 1 time in total.
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Re: Mod Rewrite Issue?

Postby vaciliy » 06. May 2011 03:21

Sharley,
Thanks. I just tried that. If I remove the trailing slash, then the links don't get structured correctly. For example:

Code: Select all
<link href="http://localhost/teststyles/style.css" rel="STYLESHEET" type="text/css" />


Where I would expect:

Code: Select all
<link href="http://localhost/test/styles/style.css" rel="STYLESHEET" type="text/css" />
vaciliy
 
Posts: 11
Joined: 02. May 2011 03:37

Re: Mod Rewrite Issue?

Postby dmsclz » 06. May 2011 03:50

What happens if you enter that target links directly into your browser?
for example http://localhost/teststyles/style.css

does it load? is this your problem? if it is not loading it maybe cause of your rewrite-rules?

Best regards,
Steffen
dmsclz
 
Posts: 35
Joined: 05. May 2011 22:41

Re: Mod Rewrite Issue?

Postby vaciliy » 06. May 2011 04:24

dmsclz, when I enter the link to the css file directly (http://localhost/test/styles/style.css), it gives me a 404 error. So, I guess it confirms you comment. How can I fix the re-write rules in htaccess? I've listed the htaccess rules in my original post.

Vaciliy
vaciliy
 
Posts: 11
Joined: 02. May 2011 03:37

Next

Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 56 guests