0

I am trying to remove the get keys from my url,

So test?category=innate&index=0 would become test/innate/0.

I have been trying all day to no avail. I find resources very hard to learn apache. Any point in the right direction would be most grateful.

2 Answers 2

1

Add these rules to the htaccess file in your document root

RewriteEngine On

# to externally redirect
RewriteCond %{THE_REQUEST} \ /test\?category=([^&]+)&index=([0-9]+)
RewriteRule ^test$ /test/%1/%2 [L,R=301]

# to internally rewrite back
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^test/([^/]+)/([0-9]+)$ /test?category=$1&index=$2 [L]
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the external as well :)
1

This rule should work for you:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^test/([^/]+)/([^/]+)/?$ test?category=$1&index=$2 [L,QSA,NC]

Reference: Apache mod_rewrite Introduction

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.