Forum Moderators: phranque
However, I don't want it to rewrite if the URI is already sub.domain.com/url
to make it more interesting /url is handled by Drupal, so I can't just create a empty url folder and put the .htaccess in there.
Any help would be greatly appreciated.
Thanks in advance.
it doesn't seem to be catching the rule.
I looked through about 20 other posts, and haven't quite found the answer.
Thanks for your help.
The RewriteRule needs two components: the requested URL (without domain and leading / here), and the server filepath of where the content is (without the domain included).
You are missing the requested URL, you'll need a (.*) on the left for that.
For a rewrite, the target should be a server filepath, so you should NOT include the http or the domain.
You asked for a rewrite, but you have included a [R=301] in the code. That is a redirect, not a rewrite.
You'll also need to test whether the rewrite is invoked by adding a RewriteCond like this:
RewriteCond %{REQUEST_URI} !(.*)url
.
A rewrite fetches content from somewhere inside the server that is hidden from the user.
A redirect forces the browser to visit a new URL. That is what the [R=301] does.
Here is what I have at the moment:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^sub-one\.domain\.com [NC]
RewriteCond %{REQUEST_URI}!(.*)url
RewriteRule (.*) [sub-one.domain.com...]
It won't load now, but it hits the rule, I end up with:
[sub-one.domain.com...] ect etc
I asked for a rewrite because I'm not sure a redirect will do it.
[sub-one.domain.com...] is generated by the application (drupal)
there is no actual url file or directory on the filesystem, does that make sense?
I'm wondering if what I'm trying to accomplish is even possible like this.
Thanks again.
When you say drupal generates URLs like "that", do you mean that it puts links in that format on the content pages, or do you mean that it responds to URL requests in that format?
[sub-one.domain.com...] but actually send [sub-one.domain.com...] to the server
I mean it responds to URL requests in THAT format, if you type in [sub-one.domain.com...] it shows the specific content.
it even confuses me when I try and explain it :>
The browser will display the same URL it sends to the server, and security considerations mean that there is nothing the server can change about that browser behaviour.
I'm going to guess that what you are struggling for is something like this:
RewriteEngine on
#
RewriteCond %{HTTP_HOST} ^sub-one\.domain\.com [NC]
RewriteCond $1 !^url/
RewriteRule (.*) /url/$1 [L]
Jim
[edited by: jdMorgan at 12:35 am (utc) on Sep. 6, 2007]
I'm still getting a loop though, now I get the following in the browser URL location:
[sub-one.domain.com...]
is it clashing with the internal drupal redirect?