I need to hide .php file name in url [duplicate] - php

This question already has answers here:
How to make .php extension not appear on website? [duplicate]
(2 answers)
Closed 9 years ago.
I want to hide the file name with the extinction of .php.I tried to write .htaccess file to restrict my URL.but it is not hiding. any one can help me step by step how to hide the URL.
bellow I mentioned actual URL.and expected URL.
Actual URL : varthakindia.com/inners.php?cid1=Hotels
Expected URL: varthakindia.com/Hotels/

In .htaccess
RewriteEngine On
RewriteRule ^Hotels$ inners.php?cid1=Hotels [L,NS]

Use mod_rewrite
RewriteEngine on
RewriteRule ^Hotels/?$ inners.php?cid1=Hotels [L, NS]

Related

.htaccess redirect to php file [duplicate]

This question already has answers here:
Reference: mod_rewrite, URL rewriting and "pretty links" explained
(5 answers)
Closed 2 years ago.
because .htacces including the syntax are totally new territory for me, I currently don't know how to create a specific redirect. I have given the following link:
www.example.com/RANDOM_STRING
This link should redirect via .htaccess to a PHP file where RANDOM_STRING is saved into a GET Parameter. Roughly speaking, it should be redirected something like this:
www.example.com/RANDOM_STRING > www.example.com/router.php?link=RANDOM_STRING
Is it even possible to redirect something like this via htaccess?
Thx
To redirect /router.php/?link=RANDOM_STRING to /router/ you can try something like the following near the top of your .htaccess file (using mod_rewrite):
RewriteEngine On
RewriteCond %{QUERY_STRING} ^link=
RewriteRule ^link/$ /link/? [R,L]

I want to rewrite a url in .htaccess file [duplicate]

This question already has answers here:
URL rewriting with PHP
(5 answers)
Closed 4 years ago.
I want to rewrite a url in .htaccess file. in localhost for localhost/pdo/connect?id=3 as localhost/pdo/connect/3 I am using this
RewriteEngine On RewriteRule ^/connect/([0-9]+)$ connect.php?id=$1 [L].
But in connect.php I am getting an error:
undefined index id in $_Get["id"]
Try this one
RewriteCond "%{REQUEST_URI} "!connect.php"
RewriteRule ^connect/([^/]+).*" "connect.php?id=$1" [L,QSA,PT]
above rule working as follow.
www.sitename.com/connect/id

How to write a php code so that I can create a link like this "http://website/2017/name.html" [duplicate]

This question already has answers here:
Reference: mod_rewrite, URL rewriting and "pretty links" explained
(5 answers)
Closed 5 years ago.
I'm sorry that my question itself is not the way it should be. I am new to php and the links to open a post ( let's take that I am creating a website something like a blog ) is like open.php?id=sth
I have seen in blogger and many other sites the links to open a post is in the type I have given in the question head. I would like to know how this is done. Is this in a way by which they create a directory and make an html file (as in the example) in that particular directory?
You can do that with a ".htaccess" file and apache url rewrite module.You don't need to create a directory.
Create a ".htaccess" file on the root folder and add something like this:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^([^?]*) ./open.php?params=$1 [L]
This will make your url like "http://example.com/2017/name"
You can debug your parameters with that code:
var_dump($_GET);
open.php?url=http://example.com
<?php
header('Location: '+urldecode($_GET['url']);
?>

Rewrite URL to MySQL value [duplicate]

This question already has answers here:
How can I create friendly URLs with .htaccess?
(8 answers)
Closed 8 years ago.
I have a PHP script that queries the database with the id specified in the URL:
http://www.example.com/articles.php?id=5
But I want the URL not to have the id in it but the title that's in the same database in another column. So I basically need to have a link that looks like this:
http://www.example.com/articles/title-of-the-fifth-article
and search for this title in the database so I can rewrite the URL in the .htacces file to where it specifies the id.
This should work:
Add this to the .htaccess file
RewriteEngine On
RewriteRule ^articles/(.*) articles.php?title=$1 [L]
and the following to the articles.php file:
<?php
echo $_GET['title'];
?>

How to generate seo friendly URLs use .htaccess with PHP? [duplicate]

This question already has answers here:
Closed 10 years ago.
I use GET in index.php:
$request=isset($_GET['m']) && $_GET['m']!='';
$requestFile=isset($_GET['files']) && $_GET['files']!='';
My link is in the format: localhost:81/Template/index.php?m=index&files=Acc.
How do I use a .htaccess file or PHP to rewrite to: localhost:81/Template/Acc/index.html or php?
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^Template/([^/]+)/([^/.]+)\.html$ /index.php?m=$2&files=$1 [L]
To obtain your page from:
localhost:81/Template/Acc/index.html

Categories