0

I need help for PHP My url is like this..............

http://localhost/cabs/airport.php?loc=majestic

and i want to change it like this.......

http://localhost/cabs/airport/loc/majestic

OR

http://localhost/cabs/airport/majestic

My code in .htaccess file

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule airport-loc-(.*).htm$ airport.php?loc=$1

Any one please help me! Thanks in advance.

3 Answers3

0

Here is the solution. Hope it will fix your issue.

RewriteEngine on    
RewriteRule ^/?cabs/airport/([^.]+)$ /cabs/airport.php?loc=majestic

updated

  • 1
    Your rule is incomplete btw, url not found error will be there and there is no L flag to stop processing and also ask op that where is he applying the rule. – Abhishek Gurjar Jul 12 '17 at 11:04
0

You may try following

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^airport/(.*) ./cabs/airport.php?loc=$1
SAMUEL
  • 8,098
  • 3
  • 42
  • 42
0

Please try it. But,only one use RewriteRule:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f

Letter only work (airport.php?loc='Abc')

RewriteRule ^/?airport/([A-Z]+)$ airport.php?loc=$1 [NC,L]

Both number and letter work(airport.php?loc='123Abc')

RewriteRule ^/?airport/([0-9A-Z]+)$ airport.php?loc=$1 [NC,L]

Number only work(airport.php?loc='123')

RewriteRule ^/?airport/([0-9]+)$ airport.php?loc=$1 [NC,L]

Url must be like:

http://localhost/cabs/airport/majestic
yekyawaung
  • 201
  • 2
  • 7