MOD_REWRITE issue

I am sure this is a simple thing but I have been messing with it for a while now… help pls…


RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(.+)\\.domain\\.tld$ [NC]
RewriteRole ^(.*)$ index.php?m=%1&n=$1 [L]

This does not work but perhaps you can see what I am attempting o accomplish here… I want the subdomain AND the request_uri to be values in a query string.

I have searched my eyes bloody.

Thanks,
Jason

RewriteRule

The rest is correct as fas as I can see :slight_smile:

Although you probably don’t need the RewriteBase

I will remove the rewrite base, the typo isnt the problem tho unfortunately, as I didnt copy/paiste but typed in it… I will try and get back…

I always find it helps to do an external redirect when debugging.

So if you change the code to


RewriteEngine On
RewriteCond %{HTTP_HOST} ^(.+)\\.domain\\.tld$ [NC]
RewriteRole ^(.*)$ index.php?m=%1&n=$1 [L,R=302]

The URL will change in your browser so you can see what’s going on. Once you have it fixed remove R=302 and all is good.

ahh thanks I didnt know about that… well I got it fixed with your earlier help…


ErrorDocument 404 http://domain.com
RewriteEngine On
RewriteCond %{REQUEST_URI} !\\.(css|js|cb|png|gif|jpg)$ [NC]
RewriteCond %{HTTP_HOST} ^(.+)\\.domain\\.com$ [NC]
RewriteRule ^(.*)$ index.cb?m=%1&pas=$1 [L]


now, here is a perhaps trivial question… if I put in:
foo.domain.com/bar
it works properly, but if I put in
foo.domain.com/bar/smile
it breaks… is there a fancy way for me to include the possibility of multiple sub-directories in the one line? I thought they would all come and I could ‘explode’ them in the application, but apparently (.*) doesnt include “/”

(.*) matches anything and everything, and that also includes slashes. I’m 100% positive about that.
Are you sure there isn’t something else going on?
Incidentally, what does /bar/smile redirect to now? Or doesn’t it redirect at all?

well it does, I see that now… I did a print_r($_GET) and got
Array ( [m] => browse [pas] => hub/bub )

from browse.domain.com/hub/bub

but all of the images, css and js breaks…

ok… I inspected the images in google chrome and I see that they are now at /hub/images/frame etc… I am going to define their locations absolutely and perhaps that will fix it…