-1

I am trying to make a php file that can be run when someone puts anything into a certain url. Say I want to go to a php script with $name as "david". Is it possible to go to a url www.-.com/Join/david and have it not go to that url, but rather a php script with a variable set to david?

  • Yes its possible but a little had with PHP, you can use PHP frameworks for that. Its called clean URL and for example; Laravel framework can be used to do that. – Derick Alangi Aug 19 '16 at 19:02
  • Yes, although it would be more along the lines of you having a page called "Join.php" and it takes a querystring of `?name=david`. You'd have a rewrite rule of some sort in your `.htaccess` that makes `www.-.com/Join/david` *actually* be a URL mask for `join.php?name=david`. – Tyler Roper Aug 19 '16 at 19:02
  • Ok I will look into that. – DeadMansMarch Aug 19 '16 at 19:02

2 Answers2

0

If you want to clean url Method then you can get All Procedure from Clean Url PHP Script

May be! Helpful to you :) If any other Problem Please Provide Some Code and Description to make Better :)

Rajpal Singh
  • 307
  • 1
  • 12
0

You can have a page called join.php that takes a querystring, like join.php?name=david

With some rules in your .htaccess file, you could then use the url /join/david/ to actually serve your join.php?name=david to the visitor.

The rules for this would be as follows:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?join/(.*?)/?$ /join.php?name=$1 [L]

Additionally, you could add the following so that if anyone actually tries to go to join.php?name=david, they are redirected to the clean URL instead:

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /join\.php\?name=([^\&\ ]+)
RewriteRule ^/?join\.php$ /join/%1? [L,R=301]

This answer references a previous answer by Jon Lin to a very similar question.

Community
  • 1
  • 1
Tyler Roper
  • 21,445
  • 6
  • 33
  • 56