.htaccess How to rewrite img.php?p=$id to img/$id? [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 9 years ago.
Improve this question
How to rewrite img.php?p=$id to img/$id in .htaccess, where $id is id of the image in database?
I tried this, but I get error - nothing found.
RewriteEngine On
RewriteBase /
RewriteRule img/^([0-9_-]+)$ img.php?p=$1
RewriteRule img/^([0-9_-]+)/$ img.php?p=$1

Replace your code with this code:
RewriteEngine On
RewriteBase /
RewriteRule ^img/([0-9_-]+)$ /img.php?p=$1 [L,QSA,NC]

Related

Why isn't my mod_rewrite working? [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 9 years ago.
Improve this question
I'l make this short and sweet:
I want to type in this:
http://pachonk.com/alex/admin/user/
And get this:
http://pachonk.com/alex/admin/index.php?page=users
I'm trying to use:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /alex
RewriteRule ^admin/([a-zA-Z0-9]+)/?$ admin/index.php?page=$1
With other variations, but this isn't working. What's wrong?
Make sure mod_rewrite and .htaccess are enabled in httpd.conf. Then put this slightly modified code in $DOCUMENT_ROOT/alex/.htaccess directory:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /alex/
RewriteRule ^admin/([a-zA-Z0-9]+)/?$ admin/index.php?page=$1 [L,QSA]

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 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?

.htaccess redirect for images [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
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]

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