Forum Moderators: phranque
i am using this code on my base directory of subdomain:
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^folder/(.*) page.php?who=$1
i want this:
when i write: subdomain.site.com/folder/kelly
it must be opened: subdomain.site.com/page.php?who=kelly
but its not working fine with this code
there is an interesting point:
when i write the adress like this:
site.com/subdomain/folder/kelly = ok, its working with the code above
but if i write this:
subdomain.site.com/folder/kelly = its not working with the same code
do u have any idea about it? what must i do?
(my subdomanis are not fake)
[webmasterworld.com...]
That example is for two parameters so you can simplify it for your application.
my english is not very vell; because of it, i couldnt understand well the content you show.
i changed my codes like this.. but it still dont work.
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^site\.com [NC]
RewriteRule ^folder/(.*) page.php?who=$1 [R=301,L]
when i write like this:
site.com/subdomain/folder/kelly = ok, its working
subdomain.site.com/folder/kelly = its not working with the same code
i want this:
when i write: subdomain.site.com/folder/kelly
it must be opened: subdomain.site.com/page.php?who=kelly
The problem may not be in the code. It may be that a request for your subdomain does not access the directory where this code is located. The .htaccess file must be in any of the directories in the requested URL-path in order to affect the request.
Jim
if change the system like this:
RewriteRule (.*) ../page.php?who=$1
its in:
http://subdomain.example.com/folder/.htaccess
my new request:
http://subdomain.example.com/folder/kelly
and it must open: http://subdomain.example.com/page.php?who=kelly
in all way.... it doesn't work:(
[edited by: jdMorgan at 1:07 pm (utc) on Oct. 28, 2008]
[edit reason] Please use example.com [/edit]
In .htaccess, the directory path to the .htaccess file is removed by the server, so RewriteRule cannot "see" it. That is, the URL-path "seen" by RewriteRule in a .htaccess file is localized to that .htaccess file's directory.
In /folder/.htaccess, try:
RewriteRule (.*) page.php?who=$1 [L]
RewriteCond %{HTTP_HOST} ^site\.com [NC] When the request is for a subdomain.site.com URL, this condition isn't met.
Am I right in thinking that you will also need a 301 redirect from site.com/folder and from www.site.com/folder over to subdomain.site.com too? Otherwise I can see at least 3 different ways for each "page" of content to be indexed.
and the code is:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^.example\.com [NC]
RewriteRule folder/(.*) http://subdomain.example.com/page.php?who=$1 [L,R=301]
still not working..
[edited by: jdMorgan at 3:34 pm (utc) on Oct. 31, 2008]
[edit reason] example.com [/edit]
example.com/subdomain/folder/name
www.example.com/subdomain/folder/name
subdomain.example.com/name
subdomain.example.com/folder/name Note that your condition is testing that "example.com" was asked for, yet you said your request was for "subdomain.example.com"- so it will not match.
Your very first example was for a rewrite, but somehow it has now morphed into a 301 redirect which is something that I am sure is not what you require for that bit.
.
You need more than one rule here. I would have thought you would want a set of redirects to fix up the URL so that the right one displays, and then a rewrite to pull the content from the dynamic filepath without exposing the filepath. That's 3 or 4 steps, and to me it looks like the redirect code you have is for a mashup of step 3 and step 4, with a condition that applies in step 1 or 2.
In the example.com/.htacess file:
301 redirect example.com/subdomain to subdomain.example.com
301 redirect www.example.com/subdomain to subdomain.example.com
301 redirect all remaining example.com to www.example.com In the subdomain.example.com/.htaccess (which is likely the same physical file as the example.com/subdomain/.htaccess file):
301 redirect example.com [1](we are in /subdomain folder)[/1] to subdomain.example.com
301 redirect www.example.com [1](we are in /subdomain folder)[/1] to subdomain.example.com
[b]Rewrite[/b] requests for folder/name to dynamic internal filepath (like your first example) [edited by: jdMorgan at 3:37 pm (utc) on Oct. 31, 2008]
[edit reason] example.com [/edit]
301 redirect example.com/subdomain subdomain.example.com
301 redirect www.example.com/subdomain subdomain.example.com
RewriteEngine on
RewriteRule ^folder/(.*) page.php?who=$1
its not working :( :( :( :(
the request must be = http://subdomain.example.com/folder/kelly
and this ruquest must go to http://subdomain.example.com/page.php?who=kelly
maybe u r explaning the wrong point; but i dont understand because of my english:( cant u write the corret code?
[edited by: jdMorgan at 3:39 pm (utc) on Oct. 31, 2008]
[edit reason] example.com [/edit]
There are limits to what we can do for you. The purpose of this forum is not to serve as a free help desk. This is a discussion forum. It will be up to you to get your code working; We will be happy to help by answering very specific questions.
I suggest that you click on the "Forum Charter" link at the top left of this screen, and read the Apache mod_rewrite documentation and regular-expressions tutorial linked from our Forum Charter. If language is a problem, try searching for a translated version of the Apache documents -- They have been translated into many languages. You might also look for a "local expert" who can help you in your own language.
Reading and writing a foreign language is difficult, I know. Reading and writing about techincal subjects is almost impossible, so you're actually doing pretty well. :)
Also, if someone gives you some code to try, put it in the specified location exactly as given to you, instead of modifying it and putting it in a different location. People will lose interest in helping if you change the problem with every post...
Best,
Jim
actually the problem is the same. i need a htaccess code for this.
http://subdomain.example.com/folder/kelly =>>>> http://subdomain.example.com/page.php?who=kelly
all the codes i tried, did not solve the problem. (i wrote above all the codes i tried)
[edited by: jdMorgan at 3:40 pm (utc) on Oct. 31, 2008]
[edit reason] example.com [/edit]
in http://subdomain/example.com/folder/.htaccess
RewriteEngine on
RewriteRule (.*) page.php?who=$1 [L]
and also i tried this too(page.php is not in "folder/" its in the base/root directory of subdomain)
RewriteEngine on
RewriteRule (.*) ../page.php?who=$1 [L]
[edited by: jdMorgan at 3:41 pm (utc) on Oct. 31, 2008]
[edit reason] example.com [/edit]
RewriteEngine on
RewriteRule (.*) [b]/pa[/b]ge.php?who=$1 [L]
RewriteEngine on
RewriteRule ^[b]folder/[/b](.*)$ /page.php?who=$1 [L]
Jim
Be careful never to use the control panel "add-on domain" commands after doing this, as the control panel script may break your config file changes.
Jim