Forum Moderators: phranque
Current .htaccess:
RewriteEngine On
RewriteRule ^/[^\?](.*)$ /?$2 [PT,NE]
What I am trying to do is this:
When someone accesses [images.example.net...] then it should redirect to [images.example.net...] See? It adds the question mark. I don't know if the problem is with my hosting provider, or my .htaccess. I don't need anything complex, so you could try using the RedirectMatch directive to do it. The .htaccess is located at [example.net...] and images.example.net maps to /images/. In /images/, there is index.php which does all the image resizing and such.
Could you help me?
[edited by: jdMorgan at 2:57 am (utc) on Nov. 21, 2004]
[edit reason] Removed specifics per TOS. [/edit]
Welcome to WebmasterWorld!
Comment:
> http://images.example.net/?screenies/
This is not a valid URL, but this would be:
http://images.example.net/?screenies
The problem is the trailing slash. It also complicates parsing out the URL, and *may* lead to a redirection loop if you're not careful. This would be the case if you needed to look for the last "subdirectory" in the URL. You'd need to look for the last slash not preceded by a question mark, instead of just looking for the last slash.
Questions:
Why are you using Pass-Through mode? Are you processing the output of this Rule through Alias, ScriptAlias, Redirect, or Redirect Match, i.e. feeding the rewritten URL from mod_rewrite into mod_alias?
Similarly, you shouldn't need to use the NoEscape flag, either.
I'll assume that you simply want to move "screenies" from a directoty-path position in the URL to a query string to be used by your php file, i.e.
http://images.example.net/screenies/ --> http://images.example.net/?screenies
and with DirectoryIndex in the "images" directory set to index.php, the effective URL then becomes
http://images.example.net/index.php?screenies
Then after another run through httpd.conf, you rewrite the subdomain to /images, and end up at
example.net/images/index.php?screenies
In that case, try:
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^screenies/?$ /?screenies [L]
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^([^/]+)/?$ /?$1 [L]
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^([^/]+)/?$ /images/index.php?$1 [L]
I'm not really sure exactly why you've got these three layers of URL-mapping, and are using PT and NE. But maybe you can play with some of these variants I've posted to see if they fit your needs.
Jim
If someone requests [images.example.net...] then I want [images.example.net...] to show up. If they want [images.example.net...] then I want [images.example.net...] to be shown. This is not a dedicated server. This is a hosting account. I would only have access to .htaccess. All 3 of the codes you gave me do not work.
Also, I'm not sure exactly what you mean by "show up". The code above is an internal rewrite. As such the content served will be from the new URL-path, but the browser address bar will not "show" any change. If you want the browser address bar to update, you'll need to use the external redirect format of RewriteRule.
Our charter [webmasterworld.com] contains links to useful references, as well as information about this forum.
Jim