Shorten URLs with htaccess - .htaccess

Using wordpress, I have already my url shortened to this domain.com/(article)/image-(image-slug)
where (article) and (image-slug) are variables.
Note that the paranthesis are here only to show what are the variables.
I want to end up whith this form of url domain.com/(image-slug) using htaccess file.

Please view this article from another user who had a similar problem, which they solved using PHP inside there .htacess.
.htaccess shorten URL using php $_GET

Related

i want a URL rewriting for my URL using only .htaccess file

My URL is
http://127.0.0.1/public_html/organisation/home/index.php?page=Your-Profile
but i want my url looks like this using .htaccess only:-
http://127.0.0.1/public_html/organisation/home/Your-Profile
i want to remove using .htaccess file index.php?page=
Please Help Me..
You can remove the /index.php as this is assumed/set by default by the engine, but you can't remove the ?page= as this is a query parameter, not part of the 'url' as you are thinking it. So it would look like http://127.0.0.1/public_html/organisation/home?page=Your-Profile
If you're using wordpress then there is an option in admin to set 'pretty urls' which would achieve this through other means.

How to remove (not hide) a subdirectory from a URL using .htacesss

I have a series of URLs on my website:
http://www.example.com/sub1/sub2/content.html
But I would like to remove "sub1" completely - not hide it so it still attempts to access that directory. Finished result would be this URL:
http://www.example.com/sub2/content.html
Many similar posts on SE seem to demonstrate how to "hide" a URL from the user. I want to rewrite the URL so that it treats it as if it isn't even there.
Example of what I'm trying not to do: Hide Part of URL htaccess
NOTE: I do not want to actually delete files as suggested by the comment below. I'm trying to redirect the request to another directory.
This worked for me:
RewriteRule ^sub1/sub2/(.*)$ /sub2/$1 [R=302,NC,L]
Helpful page: http://coolestguidesontheplanet.com/redirecting-a-web-folder-directory-to-another-in-htaccess/

links includes coma and hash htaccess

I'm using links like that:
find.php?id=1&n=2#loc
I want to my links look like:
but i dont know how to change htaccess and when/where use # to link some place in the page #loc
htaccess:
RewriteRule ^(.*),(.*),(.*)$ $3.php?id=$2&n=$1 [L,NC,NS,NE]
Help lease
The #loc part of the URL is never sent to the server, so there's no way for you to match against it in your htaccess file. Anything starting from the # in the URL is called a fragment and it's used by the browser, the server doesn't know it's even there.

IIS URL Rewrite pattern from subdirectory to subdomain with custom path extraction

Previously there was this...
http://www.website.com/blog/post/2013/04/16/Animal-Kingdom's-Wild-Africa-Trek.aspx
(notice the apostrophe in 'Kingdom's')
and its now located at:
http://blog.website.com/post/Animal-Kingdoms-Wild-Africa-Trek
so, breaking it down the parts are...
remove .aspx from the end of the URL
map the call from www. to blog. and remove the blog part of the path
remove the date from the URL
remove the apostrophe
I understand how to redirect the subdirectory to a subdomain, but im stuck extracting the other parts of the path correctly, and cleaning out the apostrophe too.
A complete solution would be a great help, thanks in advance.
There is no way to remove all ', because it can be more than one. You could try following regexp (it allows up to 4 apostrophes), but it is quite "danger":
/blog/post/\d+/\d+/\d+/(([^']*)'*([^']*)'*([^']*)'*([^']*)'*).aspx
And redirect URL will be:
http://blog.website.com/post/{R:2}{R:3}{R:4}{R:5}
Bellow screenshot of my IIS Rule:

htaccess rewrite remove filename

How can I change url in this way using htaccess?
http://www.domain.com/index.html?page=home
http://www.domain.com/indexf6f2.html?page=blog
To
http://www.domain.com/?page=home
http://www.domain.com/?page=blog
You could try to generate your own .htaccess file based on your rules using this site http://cooletips.de/htaccess/ .
Regards, Hiawatha
I am not giving exact solution. Just utilize the followings, then you will be able to solve other URL rewriting using .htaccess
Take help from the following URL
http://roshanbh.com.np/2008/03/url-rewriting-examples-htaccess.html
Other important regarding rewriting through .htaccess
http://corz.org/serv/tricks/htaccess2.php
RewriteRule to rename URL?
For a nice basic
http://www.yourhtmlsource.com/sitemanagement/urlrewriting.html

Resources