Yura Rosiak
Yura Rosiak

Reputation: 255

Configuring GET Request htaccess

My .htaccess

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php

I need to remake it to "simple" GET request.
From http://mydomain.co/page?cat=smth
To http://mydomain.co/page/smth

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php?cat=$2 [NC,L]

Can anybody show me my mistakes?

Upvotes: 0

Views: 53

Answers (1)

Joe
Joe

Reputation: 4907

The code you've tried to edit above is there to remove your .php extension. Simply adding ?cat=$2 onto the end of it will not give you clean URLs and will cause the internal error that you're getting....

What you can do is use the following rule in your .htaccess:

RewriteEngine On
RewriteRule ^page/([^/]*)$ /page?cat=$1 [L]

It will leave you with the URL: http://mydomain.co/page/smth

Make sure you clear your cache before testing this.

Upvotes: 1

Related Questions