Dynamic .htaccess using the url name - .htaccess

In a page
http://example.com/alum/
there is a link to the file
http://example.com/1.pdf
But I want to redirect to alum.pdf, using the url name in the name of the file
the same with /teac/ (for example) I want to redirec to to teac.pdf not to 1.pdf
How can I do it?
thanks!

Related

how can we add URL with more than one .php variables in .php file itself or maybe in htaccess?

the URL structure of my website is like merchantview.php?id=$id where $id echos the merchantname
at the same time, I want the open the page happening with another .php variable ...suppose merchantfullname.
e.g.
one of my merchantname is Dany while the full name is Dany-Targ
now page loads as follow
/merchantview.php?id=Dany
but at the same time, I want it also to open as
/merchantview.php?id=Dany-Targ
How can it be done?

hide (:any) from url using htaccess

I am using CodeIgniter. I want to hide the last segment from the URL. My URL is given below:
http://localhost/metropolitan/admin/home/1
I create this URL using "routes.php:, which looks like this:
$route['home/(:any)'] = 'home/content/$1';
Can anyone tell me how I can hide the last segment from the URL? Is there any method using the ".htaccess" file?

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.

Using .htaccess to redirect only certain non existing url's

I have the following scenario
I have some url's that exist and some url's that do not exist with the following structure
http://site.co.za/component/docman/cat_view/388-documents-reports/test/sss/test/123
http://site.co.za/component/docman/cat_view/388-documents-reports/file/asdsa
http://site.co.za/component/docman/cat_view/388-documents-reports/sadas
http://site.co.za/component/docman/cat_view/388-documents-reports/sadsad
What I'm trying to achieve is when any url that contains component/docman/cat_view does not exist it needs to link to the parent url
for example
http://site.co.za/component/docman/cat_view/388-documents-reports/test/sss/test/123
needs to redirect to
http://site.co.za/component/docman/cat_view/388-documents-reports
http://site.co.za/component/docman/cat_view/388-documents-reports/file/asdsa
needs to redirect to http://site.co.za/component/docman/cat_view/388-documents-reports
so in other words all urls that contain component/docman/cat_view need to redirect to the url plus the first parameter after docman
CAn this be done using the .htaccess file together with mod rewrite and how if it can?
yes using 301 redirects
see below for tutorial
http://www.phatz.com/301redirect.php

Query String Redirection using .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]

Resources