Reputation: 33
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
Upvotes: 0
Views: 46
Reputation: 332
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.
Upvotes: 1
Reputation: 11375
Try the following;
RewriteEngine On
RewriteRule ^type/([^/]*)$ /index.php?type=$1 [L]
Upvotes: 0