3 Replies - 3656 Views - Last Post: 29 October 2013 - 08:35 AM

#1 Larsonator  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 77
  • Joined: 13-August 10

Apache Subdomain with mod_rewriting - issue linking files and images

Posted 28 October 2013 - 06:09 PM

ok, so i have a local server which I am trying to develop on subdomain, because when the application goes live, it will be on a subdomain,

So, i have the following httpd-vhosts.conf setting
NameVirtualHost *:80

<VirtualHost *:80>
	DocumentRoot "C:/xampp/htdocs"
	ServerName localhost
</VirtualHost>

<VirtualHost *:80>
	DocumentRoot "C:/xampp/htdocs/test"
	ServerName test.localhost.com
</VirtualHost>


and of coarse my windows host file:
127.0.0.1   test.localhost.com


and my mod_rewrite in my .htaccess file in the base of my code ingiter application
<IfModule mod_rewrite.c>
	Options +FollowSymLinks
	Options +Indexes
	RewriteEngine On

	RewriteBase /

	RewriteCond %{HTTP_HOST} !www.localhost.com$ [NC]
	RewriteCond %{REQUEST_URI} ^/$
	RewriteCond %{HTTP_HOST} ^(www.)?([a-z0-9-_]+).localhost.com [NC]
	RewriteRule (.*) /index.php/ [P]

	RewriteCond $1 !^(index\.php|images|robots\.text|css|js)
	RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>


So this is working to an extent. I can load my controllers and pages, and logic seems to run properly, but this isn't working when its comes to linking stylesheets, and images, or java script files, even with full url's.
Eg.
File structure
htdocs
  |-test
  |  |-application
  |  |-assets
  |  |  |-css
  |  |  |  |-style.css
  |  |  |-js
  |  |  |  |-jquery.js


<link rel="stylesheet" type="text/css" href="http://test.localhost.com/assets/css/style.css/">

Request URL: http://test.localhost.com/assets/css/style.css
Request Method: GET
Status Code: 404 Not Found


Any insite as too why i am unable to link my external files?

Is This A Good Question/Topic? 0
  • +

Replies To: Apache Subdomain with mod_rewriting - issue linking files and images

#2 GunnerInc  Icon User is offline

  • "Hurry up and wait"
  • member icon




Reputation: 858
  • View blog
  • Posts: 2,281
  • Joined: 28-March 11

Re: Apache Subdomain with mod_rewriting - issue linking files and images

Posted 28 October 2013 - 06:18 PM

Just a stab in the dark here.

Look at your file structure:

File structure
htdocs
  |-test
  |  |-application
  |  |-assets
  |  |  |-css
  |  |  |  |-style.css
  |  |  |-js
  |  |  |  |-jquery.js


htdocs is the public directory that is accessed when someone types in the server name: test.localhost.com, right? What is the first subdirectory? test right?

So this:
test.localhost.com/assets/css/style.css

Should be this:
test.localhost.com/test/assets/css/style.css

(http:// removed)
Was This Post Helpful? 0
  • +
  • -

#3 Larsonator  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 77
  • Joined: 13-August 10

Re: Apache Subdomain with mod_rewriting - issue linking files and images

Posted 28 October 2013 - 06:33 PM

I gave that a go,

Removing the http:// gives a most undesired request path thanks to code igniter,

(induction being the location of the CI_Controller i am calling
http://test.localhost.com/Induction/test.localhost.com/test/assets/imgs/mic-header-logo.gif


and I get the same problem when the link is as followed
http://converge.localhost.com/test/assets/css/style.css


as a point of interest, I copied the assets folder into the htdocs folder, which is access from http://localhost, and linked that in my subdomain files and it works,
so im thinking it might have something to do with mod_rewrite, which I am admittedly still trying to understand.

This post has been edited by Larsonator: 28 October 2013 - 06:45 PM

Was This Post Helpful? 0
  • +
  • -

#4 no2pencil  Icon User is offline

  • Toubabo Koomi
  • member icon

Reputation: 5313
  • View blog
  • Posts: 27,220
  • Joined: 10-May 07

Re: Apache Subdomain with mod_rewriting - issue linking files and images

Posted 29 October 2013 - 08:35 AM

When troubleshooting subdomains, I give them their own specific error/access log, so I can validate traffic. Never rely on the hosts file solving dns issues.


<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/test"
ServerName test.localhost.com
ErrorLog logs/test.localhost.com_log
</VirtualHost>
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1