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.

0

3 Answers 3

0

You may try following

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^airport/(.*) ./cabs/airport.php?loc=$1
Sign up to request clarification or add additional context in comments.

2 Comments

No need to put scheme and host name you are not redirecting.
Thanks updated based on your comment
0

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

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

updated

1 Comment

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.
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

1 Comment

Please you use only one RewriteRule for it.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.