Reply LinkBack Thread Tools Search this Thread
Old 01-05-2007, 08:15   #1 (permalink)
freelancr
Senior Member
 
freelancr's Avatar
 
Join Date: Oct 2006
Posts: 2,174
Using mod_rewrite, is base href the best method for making things work?

I am just reading about mod_rewrite, and have just successfully made it work when testing on localhost. Though initially I had a problem making sure the links didn't break to files (images, js, css, etc)

Here is my usual file structure when testing on localhost:
localhost/website/index.php
localhost/website/css/screen.css
localhost/website/img/whatever.png
localhost/website/js/library.js

I then made a RewriteRule so pages/about -> index.php?page=1

But then all the links were broken on the page that was generated, as I link to "css/screen.css", "js/library.js", etc. So I am now using a <base href="http://localhost/website/" /> tag in the head of the page, and it makes sure the links dont become broken no matter which sub-directory of the website I am virtually in.

Is this the best method of ensuring I don't get broken links, or should I be doing something else?
  Reply With Quote
Old 01-05-2007, 14:30   #2 (permalink)
sn33kyp3t3
El guru del web
 
sn33kyp3t3's Avatar
 
Join Date: Dec 2006
Location: Tucson, AZ
Posts: 21
Send a message via AIM to sn33kyp3t3
You probably need something like:

Code:
RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f

But there is no way to know without seeing your whole .htaccess file
  Reply With Quote
Old 01-05-2007, 15:08   #3 (permalink)
pgo
Senior Member
 
Join Date: Jan 2005
Posts: 12,340
Why not set up Apache virtual hosts?

I wrote Set Up a Local Web Development Server on Windows maybe you can get some help there?

Otherwise, I'm pretty clueless when it comes to .htaccess and mod_rewrite still.
  Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Contact Us - Web Design Forums - Archive - Top
Search Engine Optimization by vBSEO 3.0.0 RC8