.HTACCESS help masking a URL [closed] - .htaccess

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]

Related

redirect 301 perment to whole site in htacess [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
i want to redirect in .htaccess all the site meaning if I go to : http://oldsite.com/sdsd.php?cal=343
it will redirect to http://newsite.com/sdsd.php?cal=343
RTFM.
RewriteEngine on
RewriteRule (.*) http://newsite.com/$1 [R=301,L]

I would like to rewrite this URL (.htaccess) [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I would like to rewrite this url in APACHE with RewriteRule
http://localhost/info.php?id=1000
to
http://localhost/folder/1000.html
I spent hours to solve this problem but it didn't work.
Without the /folder/ in the pattern it works but adding folder it does not.
This solution works:
RewriteEngine
on RewriteBase /
RewriteRule ^([\w-]+)\.html$ info.php?id=$1
but this does not work:
RewriteRule ^/folder/([\w-]+)\.html$ info.php?id=$1
What is missing
I have found the solution by removing the first slash /
RewriteRule ^folder/([\w-]+)\.html$ info.php?id=$1

Redirect Rules for .htaccess File [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
What will be the code for these redirects in the .htaccess file?
www.site.com/books/ =====> www.site.com/movies/
www.site.com/books/title/ =====> www.site.com/movies/title.html
If you need to do it as 301 redirect (and assuming your htaccess file is in the root folder), then these rules will do the trick:
RewriteRule ^books/$ http://www.example.com/movies/ [R=301,L]
RewriteRule ^books/title/$ http://www.example.com/movies/title.html [R=301,L]
Replace example.com with your domain name.
Search here in S.O. also. There are countless posts on how to do these redirections.
Edit: For dynamic titles the second rule becomes:
RewriteRule ^books/([^.]+)/$ http://www.example.com/movies/$1\.html [R=301,L]

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]

Resources