Query String Redirection using .htaccess - .htaccess

I am converting a static HTML website to a CMS.
The images folder is conflicting with a category name.
So, I would like to redirect all images in HOWTO directory like :
http://yourdomain.com/howto/images/someimage.jpg
to something like :
http://yourdomain.com/howto_imgs/images/someimage.jpg
I only want to change the image location and redirect old image URL links so they are displayed.
Any help would be much appreciated.

RewriteRule ^howto/images/(.*)$ howto_imgs/images/$1 [R=301,L]

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.

Canonical url htaccess

I am trying to achieve certain thing via htaccess file.
I would like this
http://mypage.com/e-store/561/
http://mypage.com/e-store/562/
to look like this
http://mypage.com/tv-screens
http://mypage.com/computers
I have read that it is possible via htaccess with rewrite urls. But I cant manage to wrap my head around it.
Use this is .htaccess file:
RewriteRule ^([-a-zA-Z0-9_]+)/$ ?url=$1 [L]
And add in your code output pages as:
http://mypage.com/?url=tv-screens
Where on the parameter URL the necessary page is displayed.
This link doesn't display page screen name:
http://mypage.com/e-store/561/

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.

Rewriting different URL from one page to another using .htaccess

I need to know if there is a way to redirect long URLs to short URLs.
I have an RSS page that will list out a number of news items from my website. The URL format of each item (as per MySQL query) is something like http://example.com/news.php?id=2.
On my news.php (after being redirected to the news page upon clicking on any news title on the RSS page), there are parameters set to carry along the IDs which looks like http://example.com/news.php?news=2&view=1&topic=12.
For SEO purpose, I need to erase that dirty query string so that viewers will only see http://example.com/news.php?id=2 while on the server-side, it actually reads http://example.com/news.php?news=2&view=1&topic=12.
I had created an .htaccess file and it is placed inside the rss folder (where the rss.php file is located ) and tried several attempts but to no available.
Help me on this.
Here's what I would do:
RewriteEngine on
# id + view + topic
# http://www.domain.com/news/1/1/12 will load: /news.php?news=1&view=1&topic=12
RewriteRule ^news/([0-9]+)/([0-9]+)/([0-9]+)(/?)$ /news.php?news=$1&view=$2&topic=$3 [QSA,L,NC]
Please this .htaccess in the root folder.
Should the parameters be assigned to ($1,$2,$3...etc) instead?
RewriteRule ^news(/?)$ /news.php?news=$1&view=$2&topic=$3 [QSA,L,NC]

.htaccess ModREwrite

This is a totally new area for me so please be patient. I want to create "permalinks" for a dynamic site I am working on. At the moment all the pages (not the index) are referenced using an ID variable thus:
http://www.domainname.com/page.php?ID=122 (etc)
I want to create a suitable rewrite rule so that a useable URL would be more like this:
http://www.domainname.com/page/'pagetitle'.html (could be .php doen't matter)
Page title is stored in the database and obviously is linked directly to the ID
Am I right in thinking thr rewrite rule would be something like this?
RewriteCond %{QUERY_STRING} ^(([^&]*&)*)ID=([^&]+)(&+(.*))?$
RewriteRule ^page\.php$ /page/%3?%1%5 [L,R=301]
My ideal would be to just create
http://www.domainname.com/'pagetitle'.html
But have absolutly no idea how to do that.
Now the other question/sub question.
If the rewrite works i.e. you type in http://www.domainname.com/page/'pagetitle'.html to a browser address bar does the htaccess file work "the other way" in accessing the page http://www.domainname.com/page.php?ID=122 or do I have to create a function to take the 'pagetitle'.html bit of the URL and convert it to page.php?ID=122 ?
Also, sorry, but this is all new; if I create a site map (xml or php etc) using http://www.domainname.com/page/'pagetitle'.html will the SE spiders go to http://www.domainname.com/page.php?ID=122? or di I need to create the sitemap using the ID variables?
Question 1 and 2:
The condition is not required in this case. Use it like this:
RewriteRule ^/page/([\w-]+).html$ /page.php?title=$1 [L,R=301]
This transforms
/page/blabla.html to /page.php?title=blabla
You need to find the right page using the title parameter in page.php
Question 3:
I suggest you never use the querystring variant of the urls in any of your anchor links or xml sitemap. This way the spiders will only know of the friendly urls.

Resources