Remove = and ? from URL from get method in PHP

I want to remove the = and ? from the URL from the get method in PHP. I’m working on the pagination structure of my website and currently this is what the URLs look like:


Open in new window

I want it to look like this:


How would I rewrite that with htaccess?

This is what my htaccess file looks like right now:

RewriteBase /  
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html
RewriteCond %{REQUEST_URI} /index\.html?$ [NC]
RewriteRule ^(.*)index\.html?$ "/$1" [NC,R=301,NE,L]

Have you considered a more general solution such as a router? Plenty to choose from.

1 Like

Not at all. mod_rewrite does the opposite, it converts www.example/test/3 into www.example/test/?page=3. And (probably the most misunderstood part about mod_rewrite) the rewriting happens between Apache and PHP, so no-one will ever see the work done by mod_rewrite.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.