Forum Moderators: phranque
Here is my problem.
First, i have my domain: www.example.com, with two subdirectories ( /sub1 and /sub2 )
I have done a redirect from www.example.com to /sub2
Now, i want that the people who enter in the /sub1, be redirect to the www.example.com directory.
I have done this with this code:
RewriteEngine on
RewriteRule ^(.*)$ http://www.example.com/ [L,R=301]
Now, i want that the people who enter into /sub2/modules.php?name=ForumsANDSOMEMORETEXTHERE, see the page with normality, and when a person want to enter on any page inside the /sub2 directory, i want to be redirected to www.example.com.
Note that, i want a redirection of all the files and querys inside /sub2 to www.example.com, however, when you the page:
/sub2/index.html nothing hapens and the same whit /sub2/modules.php?name=ForumsSOMETEXT pages.
I tried doing this:
RewriteEngine onRewriteCond %{HTTP_HOST} !^modules\.php\?name=Forums [NC]
RewriteCond %{HTTP_HOST} !index\.html$ [NC]
RewriteRule (.*) http://www.example.com/ [L,R=301]
I tried doing as well with %{QUERY_STRING}, %{HTTP_HOST}, and %{REQUEST_URI}.
Any suggestions?
Thanks for reading.
PD. Sorry for my english, i'm spanish.
[edited by: coopster at 1:34 pm (utc) on Nov. 20, 2008]
[edit reason] one domain was missed, changed to example.com [/edit]
So if you want to test or create back-references to various 'pieces' of the request sent to your server, you must use separate RewriteConds to do so.
You cannot use something like "RewriteCond %{HTTP_HOST} !^modules\.php\?name=Forums [NC]" because HTTP_HOST will never contain either "modules\.php" or "name=Forums". It will contain only the requested hostname, for example, "example.com".
If you have not already done so, find and read the mod_rewrite documentation, and the Apache URL Rewriting Guide. It is possible that you may be able to find a Spanish translation of these documents -- Search for this Apache documentation looking for search results from the Web sites of technical universities in Spain and other Spanish-speaking countries. Otherwise, all of the documentation is available in English from apache.org.
Also, find and read a Regular Expressions tutorial for help creating and using regular expressions for pattern-matching.
Links to the mod_rewrite documentation and to a regular-expressions tutorial (in English) are available in our Apache Forum Charter [webmasterworld.com].
You may also find the Apache section of our WebmasterWorld Library [webmasterworld.com] to be useful.
If you could describe you over-all goal here, that would simplify things. It is important to fully-define your requirements and your "plan" before moving into the coding phase.
It is best to look at the problem like this:
Jim