I am working on URL of my website. I have just rewrite the URL From
http://www.website.com/index.php?url=some-text
to
http://www.website.com/some-text
For this I'm using following code of .htaccess
Options +SymLinksIfOwnerMatch
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ index.php?url=$1 [L,QSA]
Now, I want to add another variable page number
in URL.
http://www.website.com/index.php?url=some-text&page=1
I want to rewrite it like
http://www.website.com/some-text/1/
AND
http://www.website.com/some-text/1
I have tried following code but some reason it is not working, it showing me server error.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)/(.*)$ index.php?url=$1&page=$2 [L,QSA]
RewriteRule ^(.*)/(.*)/$ index.php?url=$1&page=$2 [L,QSA]
You don't need 2 new rules. Just one with optional
/
will be enough. Your complete code:Another problem in your new code is that
RewriteCond
are not getting applied for lastRewriteRule
since these are applicable to very nextRewriteRule
only.