-3

How can i add .php at the end of url using .htaccess and below is .htaccess code

.htaccess

<IfModule mod_rewrite.c>
# Enable Rewriting
RewriteEngine on

RewriteRule ^search/(.*)/?$ search.php?loc=$1

</IfModule>

search.php

if the url is

search.php?loc=miami

echo "Location : " . $_GET['loc'];

output: Location : miami

but how can get search.php/miami.php in the end ?

3
  • Of course the loc GET parameter doesn't have .php, you would need to request search.php?loc=miami.php for that. What exactly are you trying to achieve here? Commented May 25, 2012 at 13:34
  • Do you mean you want to turn search/miami into search.php?loc=search.php/miami.php? Commented May 25, 2012 at 13:35
  • possible duplicate of Using mod_rewrite to hide .php from the end of URLs -- Albeit I'm not sure either what's being asked here. Commented May 25, 2012 at 13:36

1 Answer 1

1
RewriteRule ^search\.php/(.+)\.php$ search.php?loc=$1
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.