Reputation: 51
i want rewrite my url this is my index.html page
<a href="http://localhost/htac/index.php?url=main&page=1">Main</a> <br>
<a href="http://localhost/htac/index.php?url=about&page=2">About</a> <br>
<a href="http://localhost/htac/index.php?url=contact&page=3">Contact</a> <br>
this is my .htacees file
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/([a-z])/([0-9])?$ index.php?url=$1&page=$2 [L]
i want change my url to
http://localhost/htac/index/about/2 (http://localhost/htac/index/{url}/{page})
but url is :
http://localhost/htac/index.php?url=about&page=2
Upvotes: 1
Views: 114
Reputation: 785126
Have your /htac/.htaccess
like this:
RewriteEngine on
RewriteBase /htac/
# external redirect from actual URL to pretty one
RewriteCond %{THE_REQUEST} /index\.php\?url=([^\s&]+)&page=([^\s&]+) [NC]
RewriteRule ^ %1/%2? [R=302,L,NE]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)/?$ index.php?url=$1&page=$2 [L,QSA]
You need to change source of your HTML to have links as: <a href="http://localhost/htac/main/1">Main</a>
Upvotes: 2