Reputation: 909
It looks like there are many questions on here regarding RewriteRules, relative paths, and redirecting without changing the URL - however, in all of my searching, none of them seem to answer my specific scenario.
Here is my current .htaccess file:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond {REQUEST_FILENAME} !^images
RewriteRule ^files(.*)$ ../../fileManager/server/php/files$1 [L]
Basically what this is doing is, if the URL someone enters contains the word "files" after the root directory, it then redirects them to a path which is up two directories, which actually contains the file.
For example, if you go to "http://www.example.com/files/username/myImage.jpg", it will actually redirect you to "http://s281192971.onlinehome.us/cms/fileManager/server/php/files/username/myImage.jpg".
The problem with this is that it works great locally, but when I upload it to my server, it stops working.
One way I found around this was to just specify the absolute path to the file path like so:
RewriteRule ^files(.*)$ http://s281192971.onlinehome.us/cms/fileManager/server/php/files$1 [L]
And that "works" - but the problem is, it changes the URL as well. I would prefer to keep the URL that the user typed in (http://www.example.com/files/username/myImage.jpg", rather than the absolute path.
Is this possible?
Upvotes: 1
Views: 4910
Reputation: 17361
I didn't try this but the docs state you can use the URL-path for substitution.
http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewriterule
My guess would be making your rule like:
RewriteRule ^cms/mysite/files(.*)$ /fileManager/server/php/files$1 [L]
Upvotes: 1