Symlink in htaccess file - .htaccess

I want to specifically symlink the following files:
http://domain.xx/File_Name_6173.zip (/public_html/File_Name_6173.zip)
http://domain.xx/File_Name_7892.zip (/public_html/File_Name_7892.zip)
http://domain.xx/File_Name_1868.zip (/public_html/File_Name_1868.zip)
To: http://domain.xx/File_Name.zip (/public_html/File_Name.zip) with only the use of the .htaccess instead of manually typing 'ln' commands in ssh.
So I can easily manage all the symlinks with .htaccess.
Is this possible using RewriteCond and RewriteRule?
Please help me out! Thanks in advance!

Related

How to rename Webdav folder in another

In my server with apache and mod_dav have the following webdav rules in config
Alias /admin_folder /var/www/test_site_cloud/web/admin_folder/files
so I have /admin_folder mount.
Now I need to rename another folder inside this Alias
/admin_folder/foo/bar into /admin_folder/foo/new_name_folder
There is some method??
I try with mod_rewrite but in my webdav client don't work....
RewriteEngine on
rewriterule ^admin_folder/foo/bar(.*)$ admin_folder/foo/new_name_folder$1 [r=301,nc]
This is not going to work because the webdav module is not aware of how things were rewritten. You might be able to do it with a symlink, if mod_dav follows those, otherwise you are out of luck.

Rewrite Rule to Create Directory Shortcut

I have a file that is located at:
http://www.mydomain.com/alcamino/includes/display_objects/custom/camino-tools/RemotingService.cfc
I would like to be able to access RemotingService.cfc like this:
http://www.mydomain.com/remoting/RemotingService.cfc
I have tried several different Rewrite rules but none are working correctly.
Can anyone point me in the right direction?
Thanks
Try adding this in the htaccess file in your document good
RewriteEngine On
RewriteRule ^/?remoting/RemotingService.cfc$ /alcamino/includes/display_objects/custom/camino-tools/RemotingService.cfc [L]

htaccess rewrite resulting in 500 Internal Server Error

I am trying to get pretty urls using htaccess for SLIR image resizing plugin.
I want to rewrite something like below:
Before Rewrite:
localhost/img/600x400/slider/image.jpg
After Rewrite
localhost/application/public/slir/index.php?r=slir&w=600&h=400&i=img/slider/image.jpg
But the following code is returning a 500 Internal server error...
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)/([0-9]{1,4})x([0-9]{1,4})/(.*)\.(gif|jpg|jpeg|png) application/public/slir/index.php?r=slir&w=$2&h=$3&i=$1/$4.$5 [NC,NE,QSA,L]
</IfModule>
Please help me.....
UPDATE
I thought it was a File Permissions issue...
so I checked all the related directories and files, surprisingly there were all 755/644.
Then I directly checked the /application/public/slir/index.php. It was not accessible.
I created another file named hello.php in the same slir directory and hello.php was accessible.
Then I moved the SLIR directory to the another folder named public. Here, both the index.php and hello.php were accessible.
After that, I moved SLIR directory to back to the original scripts folder. In scripts folder, hello.php is accessible but index.php is not accessible.
Now, Both files have same permissions and are in same folder.. I dont know what is happening here... :/ :/
Someone please help me......
In case anyone else is looking at this - the problem I found was these two lines in the htaccess file:
php_value auto_prepend_file none
&
php_value auto_append_file none
some servers don't allow them.
moving them to my php.ini file solved it for me:
auto-prepend-file = none
auto-append-file = none
That is probably because you are editing the .htaccess file with a Windows based editor like notepad. Notepad adds some characters to the file which you can't see, but they mess with the .htaccess. I recommend using an editor like Notepad++ and setting the mode to Unix, so it won't mess with the server..
Speaking technically that is because Linux and Windows have different type of EOL ( End Of Line ) so that notepad adds some characters to the end of every line to go to the next line, but Unix won't recognize them, because it has it's own type of EOL..
Slashes are normally forbidden in query strings, but you can enable them by setting
AllowEncodedSlashes directive.
You may also want your rewrite rule to use percent encoding for slashes (that is %2F) so after rewrite:
localhost/application/public/slir/index.php?r=slir&w=600&h=400&i=img%2Fslider%2Fimage.jpg
See also How do you configure apache php to accept slashes in query strings
Duplicate, phrased very differently:
Has anyone used Smart Image Resizer on subdomain sites?
The problem is the subdomain...

htaccess mod_rewrite directory to variable

I'm having some trouble with mod_rewrite in my .htaccess file.
I've found numerous tutorials about how to do the reverse of what I'm trying to accomplish.
Basically I need a solution to change directories to get variables.
So that this:
http://example.org/page-1
turns into
http://example.org/?link_id=page-1
I think I got a code that would do something almost to what I need, but I was getting redirect loops.
Here you go:
RewriteEngine On
RewriteRule ^page-([0-9]*)$ index.php?link_id=page-$1
Note: I'm not sure that index.php is your DirectoryIndex. If it's not, you should change it according to your index file.

How to make mod_rewrite *not* perform home directory expansion when using .htaccess

Filepath: /Users/user_name/Sites/example.com
Browseable at: http://localhost/~user_name/example.com/
In a child directory (chrome) I got a .htaccess like this:
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^rgba\((\d{1,3}%?,\s?\d{1,3}%?,\s?\d{1,3}%?,\s?[0-1]?\.?\d+)\)$ rgba.php?rgba=$1 [PT]
This matches a request like:
http://localhost/~user_name/example.com/chrome/rgba(255,255,255,0.5)
and should rewrite the request to:
http://localhost/~user_name/example.com/chrome/rgba.php?rgba=(255,255,255,0.5)
I put the rgba.php in the chrome directory. Still I get this error msg:
The requested URL /Users/user_name/Sites/example.com/chrome/rgba.php was not found on this server.
I read the part in the manual about Home directory expansion and the [PT] flag but it makes no difference.
If i put up a vhost pointing to the example.com directory it works. I would like it to work both ways =P
So how do I do it?
I run Apache/2.2.15 (Unix) on a Mac OS X
EDIT
AllowOverride is set to All for the users Sites directory. If it wasn´t the rewrite shouldn´t have worked at all.
I spent half a day wracking my brains on this and the only solution I could find was to create a new VirtualHost with the DocumentRoot set to the user's home directory.
Holy god that was frustrating. But I have it working.
I tried a bunch of stuff. I thought that the PT flag on the RewriteRule would fix it, but nope.
I still don't know how to stop the home directory expansion, but I figured out a workaround. Just before the RewriteRule, use RewriteBase /~user_name/example.com/chrome/. This overrides the rewrite's prefix (log entry from my config):
<SNIP> (2) [perdir /Users/colin/Sites/ajaxtest/] trying to replace prefix /Users/colin/Sites/ajaxtest/ with /~colin/ajaxtest/
UPDATE
This solution works somewhat, but it appears to make the rewrite engine trigger twice... once for the internal redirect, and again afterwards. I ended up just using a VirtualHost like the other submitter.
Allow overrides in you configuration file for your home directories.

Resources