Forum Moderators: phranque

Message Too Old, No Replies

mod rewrite dynamic folders

mod_rewrite dynamic folders

         

wilorichie

4:20 am on Jun 12, 2007 (gmt 0)

10+ Year Member



Options +Indexes
Options +FollowSymLinks
RewriteEngine on

RewriteBase /

RewriteRule ^index\.isindex.php [L]
RewriteRule ^about\.isabout.php [L]
RewriteRule ^login\.islogin.php [L]
RewriteRule ^register\.isregister.php [L]
RewriteRule ^contact\.iscontact.php [L]
RewriteRule ^profile\.isprofile.php [L]
RewriteRule ^search\.issearch.php [L]

RewriteRule ^display/([0-9]+)/([0-9]+)/([_0-9a-zA-Z-]+)\.is$pdisplay.php?prodc=$1&prods=$2&scn=$3 [L]

This is my .htaccess file.

When I click on pdisplay/$id/$id2/$name it takes me to pdisplay.php?prodc=$1&prods=$2&scn=$3 which is correct.

Now, the problem: When I arrive to pdisplay.php it thinks that all the files are in the folder pdisplay/$id/$id2/$name. There is no such folder structure. All the files are on the root. Becuase of this, my CSS is not loading and the website looks like junk. All my links are linked to pdisplay/$id/$id2/$name/about.is etc...

How do I assign my new redirect it realises that pdisplay/$id/$id2/$name are just fake folders and the real folder is the root?

jdMorgan

4:30 am on Jun 12, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The problem is that it is the client (browser) that resolves relative links, and the browser naturally thinks that relatively-linked objects are located relative to the subdirectory specified by the current URL in its address bar.

Either rewrite all css, image, and external JavaScript files back to root, or link to them using server-relative or canonical links; i.e. <img src="/logo.gif"> or <img src="http://www.example.com/logo.gif">

Jim

[edited by: jdMorgan at 4:33 am (utc) on June 12, 2007]

wilorichie

4:38 am on Jun 12, 2007 (gmt 0)

10+ Year Member



Ah crap!

Alright, thanks mate.