0

This is my htaccess file:

Options -Multiviews

RewriteEngine on
RewriteBase /

RewriteRule ^index.php$ / [L,R=301]
RewriteRule ^(.+)/index.php$ /$1/ [L,R=301]

This has successfully removed index.php but left ? before query string like

http://example.com/?type=1

How can I remove this '?' using htaccess

Also, how can I actually show above url as:

http://example.com/type/1
1
  • Now following is my .htaccess Commented Jan 5, 2014 at 18:28

2 Answers 2

1
RewriteEngine on
RewriteRule ^type/([^/.]+)/?$ index.php?type=$1 [L]

How it works

The RewriteRule ^type/([^/.]+)/?$ means that it's setting the URL of your path to type/5*/ *= whatever number is put in there.

Then the information given in the new url would then pass it to the index page. (index.php?type=$1 [L])

So for example, if you had type/1 it would forward that to index.php?type=1

I hope that this helps you and you now have a wider understanding of how it worked.

Sign up to request clarification or add additional context in comments.

Comments

0

Try the following;

RewriteEngine On
RewriteRule ^type/([^/]*)$ /index.php?type=$1 [L]

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.