views:

46

answers:

4

I have made an .htaccess to my root directory for creating a subdomain level, assume it is sub.domain.ex that redirect to domain.ex/deb/

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} sub.domain.ex
RewriteCond %{REQUEST_URI} !deb/
RewriteRule ^(.*)$ /deb/$1 [L]

and this works well.

Now, I go to /deb/ and create another .htaccess with the following

RewriteEngine on
RewriteRule ^([^/]+)/ /deb.php?app=$1 [NC]

the deb.php is a file that prints the argument "app". It works but only if i call http://sub.domain.ex/something/ (note the slash at the end). It only works with a final slash, if I remove it, it doesn't and I want it to work without final slash.

So I change the rule into ^([^/]+) but now I have 500 Apache internal error. The regex coaches are by my side with the selection, maybe I'm missing something. Thanks


UPDATE

I'm runinng mad. Mybe is wrong to put one .htaccess in the root for creating se 3th sublevel doman and the .htacces in the other directory? Because I'm ttrying some trick. I use this rule

RewriteEngine on
RewriteRule ^([^/]+)/ deb.php?app=$1 [NC]

in the .htacces of the /deb directory and made a print_r($_GET); and called index.php. So the redirectory doesn't work at all if it forward me on the index.php of the cydia sublvel and doesn't take the /deb/deb.php!!! Recap. my dir structure is this:

/htdocs/ -> the root of the main domain level like www.example.com
---index.php -> home file of www.example.com

/htdocs/deb -> the root directory of the 3th sublevel domain (subdomain.example.com ->
---index.php
---deb.php

So the .htaccess for the 3th level domain is the in /htdocs./htaccess and described as before. The other .htaccess for "beautify" the link is in the /htdocs/deb/.htaccess. I want that when you go to subdomain.domain.com/someText it transform to deb.php?app=someText

Now i tryed go to subdomain.domain.com/deb.php....WTF!? the deb.php is in /htdocs/deb/deb.php

Home is clear

A: 

I could be wrong, but in the second .htaccess you should check that the url wasn't yet rewrited with "/deb.php"

So something like

RewriteCond %{REQUEST_URI} !deb\.php
RewriteRule ^([^/]+) /deb.php?app=$1 [NC]
Riccardo Galli
thanks but this is no possibile. the redirect url is good because if a I call the site sub.domain.ex/testname it echo the content of the php file place on /deb/deb.phpIn case just echo the $_GET['app'] value, just for testing. so the problem ie elsewhere, I think in the rgeex but I cant figured out
Kreker
A: 

You rewrite rule should be

RewriteRule ^(.*)$ deb.php?app=$1 [L,QSA]

That's a common pattern used in CMSs like Drupal

Claude Vedovini
didn't work either:(. and i'0ve tryed with regcoach and with yours it select me all the letter typed
Kreker
this cause 500 apache internal error now
Kreker
+1  A: 

This works fine for me, at least, assuming I understood everything you wanted.

In /htdocs/.htaccess:

RewriteEngine On
RewriteCond %{HTTP_HOST} =sub.domain.ex
RewriteCond %{REQUEST_URI} !^deb/
RewriteRule ^(.*)$ /deb/$1

In /htdocs/deb/.htaccess:

RewriteEngine On
RewriteBase /deb/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/?$ deb.php?app=$1
RewriteRule !^deb.php index.php

Edit: I updated the second file's contents to reflect your additional requests. You should remove the /? if you don't want them to be able to go to sub.domain.ex/something/ -> deb.php?app=something.

Tim Stone
ok this is going to works, but with I have the possibility to call the url iwth many parameters like subdomain.domain.com/test1/test2/ etcit's possible to block only iwth one paramater without the final slash??
Kreker
What do you want test1/test2/ to point to in terms of the files you have and their query strings?
Tim Stone
there is another problem with your solution. I get this when I print $_GETArray ( [app] => deb.php ) and it's not the argument we passed
Kreker
I want the when you to /test you'll redirect to /deb/deb.php?app=testif you type more slassomething like /test/moretest/andmore u go to the index of dthe deb dir.At least maybe that works with and without the final bar! I get always 500 apach erro when I put for only one paramataer
Kreker
You copied exactly what I had and you get `Array ( [app] => deb.php )`? Hmm...I get `Array ( [app] => something )` as expected, weird. I updated my answer to deal with your second comment, but I'm still trying to think of why you'd be getting `app=deb.php` when I'm not.
Tim Stone
A: 

I think there is some kind of rescrctions to my host. It's impossible. I tried all kind of goo (for a regexcoach) for matching the correct group and there is nothing else the 500 error apache. The only way to get this to work is use tu parameters with this ^app/([^/]+) /deb.php?app=$1 and calling with sub.domain.com/app/nameTest and this is working with or without the end backslash. Of you get some advice for getting rid of this, please let me know. bye

Kreker