.htaccess redirect for images [closed] - .htaccess

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I have an image uploader. I would like for the users to be able to access there files by going to
http://sub.domain.com/4ed7612d52d57
using .htaccess. the original file is
http://sub.domain.com/msc4ed7612d52d57.png
any help appreciated!

RewriteEngine On
RewriteRule ^(.*)$ msc$1.png [L]
This will rewrite all requests that fall through this .htaccess file so that msc in prepended, and .png is appended. This may not be exactly what you want, but according to all the information in the question it is the best I can do...

If your files are only .png , better to add prefix 'images/'
http://sub.domain.com/images/933asdad
RewriteEngine on
RewriteBase /
RewriteRule ^images\/([a-z0-9].+)$ http://sub.domain.com/$1.png [L]

Related

.HTACCESS help masking a URL [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
My current URL is
http://domain.com/directory/page.php
I would like the page to be accessed and addressbar to keep it as
http://domain.com/page
is this possible with htaccess?
You'll need to enable mod_rewrite. Then, you can put something like this in your .htaccess file:
RewriteEngine on
RewriteRule ^/page$ /directory/page.php [L]
If you want to do this for all of the php scripts in /directory/, you could do this instead:
RewriteEngine on
RewriteRule ^/([^/]+)$ /directory/$1.php [L]

htaccess rewrite part of filename to url [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I can't figure out how to rewrite this:
/part-filename.php
to
/part/filename.php
/part/ is not an existing directory.
I know it should be quite easy, but can't find how to search for 'part' in the filename and translate that to a sub level in the url.
Thanks in advance for your help!
Try this
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^part/(.*)$ /part-$1 [L,QSA]
</IfModule>

htaccess, folder to folder redirect has some problems [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I have a problem redirecting a folder to another one.
The rule seems to "work" but it stumble at some point adding some other stuff.
Here an example:
The goal is to redirect traffic from oldfolder (not existing anymore) to newfolder.
www.domain.com/one/oldfolder/year/ --> www.domain.com/one/newfolder/year/
So i set up the following rules (first one for the canonical url):
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain.com$
RewriteRule ^/?$ "http\:\/\/www\.domain\.com" [R=301,L]
RewriteRule ^(.*)/oldfolder/(.*)$ $1/newfolder/$2 [R=301,L]
The problem is that it redirects to:
http://www.domain.com/home/username/public_html/www.domain.com/one/newfolder/year/
Anyone can spot the problem in the rule i wrote?
Thank you very much for your help.
Check your DocumentRoot
Check the Directory directive
Make sure you have RewriteBase / if this .htaccess file is in your document root.

htaccess rewrite image URLs [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
How can i rewrite dynamic image URLs to their original origin?
Example url
/images/products/2658-14732-sergeant-dolly-jacket-olive-full.jpg
Real filename
/images/products/0002658/0014732_full.jpg
I now use a 404 page redirect to a php script but this uses a unneccesary amount of impact on the server and somehow blocks VPNs.
I came this far but can't find out how to add leading zeros.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^images/([a-z_-]+)/([0-9]+)-([0-9]+)-(.+)-([a-z]+).jpg$ /images/$1/$2/$3-$5.jpg [L,QSA]
</IfModule>
Try this:
RewriteRule ^(images)/(products)/([0-9]+)\-([0-9]+)\-(?:.+)\-(full).jpg$ /$1/$2/000$3/00$4_$5.jpg
Do the zero's on these0002658 0014732 numbers change?

advance url rewriting [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
how can i change
http://www.mydomain.com/down.php?key=1223
to
http://www.mydomain.com/?k=1223
i have google it but not found any ans...please help me...
i am using apache server with unix
You should use mod_rewrite. Add to your .htaccess file those lines:
RewriteEngine On
RewriteBase /
RewriteRule ^\s+\.php\?key=(\d+) \?k=$1
Read about mod_rewrite and RewriteRules here:
http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html#RewriteRule
RewriteCond %{QUERY_STRING} key=(.*)
RewriteRule /down.php /?k=%1 [R]

Resources