hide (:any) from url using htaccess - .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?

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 display post name right after domain through .htaccess

I have listed post form page articles which currently looks like this:
http://demo.web/articles/hello-world
and I just want to display url which will look something like this: http://demo.web/hello-world
but the problem is the page articles will fetch the data with the id passed in the URL.
And, I have also listed other article on the same page with the title other posts. I am already inside http://demo.web/articles/hello-world and if I hover over other links of the same page then it gives url which looks like this:
http://demo.web/articles/2/hello-world/articles/3/life-is-beautiful
What I mean to say is the URL is being appended in the existing URL.
At the end what I want my url to look like this: http://demo.web/hello-world or http://demo.web/life-is-beautiful
My .htaccess file have the following code:
RewriteEngine On
RewriteRule ^([a-zA-Z]+)$ $1.php
RewriteRule ^articles/([0-9]+)/([a-z-]+) articles.php?id=$1&act=$2
Its like you are rewriting as a relative path.
Try adding / in front "articles.php?id=$1&act=$2"

Dynamic .htaccess using the url name

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!

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.

htaccess remove part of the url

I have urls structured like this:
/!#/pretty-url/
I need to remove the !# so the urls will look like this:
/pretty-url/
What would be the correct .htaccess rule to do this?
When you have a # in the URL then that is a named anchor. The browser does not send anything to the right of a # to the server. This means that all the rewrite engine is seeing is:-
/!
If you want your URLs to look like this then you are going to need to use JavaScript to get the relevant content via AJAX.

Resources