Forum Moderators: phranque

Message Too Old, No Replies

mod rewrite help - constant var passed

         

StevenBullen

8:48 am on Jan 7, 2008 (gmt 0)

10+ Year Member



Hi,

Looking for a little help and come across webmaster world.

Basically I am using the rules below and trying to do the following... :P

I would like
http://www.example.com/testing/login.php
http://www.example.com/thistest/login.php
to be passed as
http://www.example.com/login.php?test_name=testing
http://www.example.com/login.php?test_name=thistest

Rules

RewriteEngine On
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^([^/¦.]+)/(.*)\?(.*)$ /$2?$3&test_name=$1 [L,NC,QSA]
RewriteRule ^([^/¦.]+)/(.*)$ /$2?test_name=$1 [L,NC,QSA]
RewriteRule ^([^/¦.]+)$ /index.php?test_name=$1 [L,NC,QSA]

It works... sort of... :(
My problem is that my stylesheets are in css folder. So when I direct to
http://www.example.com/css/style.css
or
http://www.example.com/testing/css/style.css

it will not let me see the css.

Sorry if it dont make sense... ha ha!

StevenBullen

9:00 am on Jan 7, 2008 (gmt 0)

10+ Year Member



Also side question as well if possible...

Is it possible to do simliar to above but have the following?

[testing.example.com...]
[thistest.example.com...]
to be passed as
http://www.example.com/login.php?test_name=testing
http://www.example.com/login.php?test_name=thistest

jdMorgan

12:15 am on Jan 8, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Relative links on your pages, such as the CSS file URLs, will be resolved by the browser based upon the page URL that it 'sees' in its address bar. So, you will either need to rewrite the css file URLs, or you will need to use server-relative or canonical URLs for the css files (as well as other included objects such as external JavaScripts and images).

<img src="images/logo.gif"> is page-relative, and will give you the same kind of problem as you report with css.
<img src="/images/logo.gif"> is server-relative, and should work.
<img src="http://www.example.com/images/logo.gif"> is canonical and should work.

You can apply the same technique to your css file includes.

Jim