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?
Related
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]
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 9 years ago.
Improve this question
I have a domain set up as shop.mydomain.com - however the domain name is changing to just www.mydomain.com
So, all traffic that comes in for shop.mydomain.com, needs to redirect to www.mydomain.com
E.g. shop.mydomain.com/product001.html need to redirect to www.mydomain.com/product001.html
Is this possible with a rewrite rule? All site URLs remain the same, but they now reside on www.mydomain.com as opposed to shop.mydomain.com
Thanks in advance!
Per this article
RewriteCond %{HTTP_HOST} ^shop.mydomain.com$ [NC]
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [R=301,L]
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>
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]
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]