Solve problem with URL rewrite with .htaccess


I am writing a web application in PHP. I’m trying to rewrite urls with this pattern:

from the pattern:

I am using here the PHP $_GET method and calling with the var $_GET[‘url’]. And It is working great on almost any cases.

But when I’m trying to use a string value rather than variable the problem arises. The problem happening with the trailing slash at the end of the url. This problem also happening for folder. For example “blog“. It can be a folder or string. In this case when I use this $_GET method the url exposes without trailing slash something like this: - OK, the url stays just like that and its fine.

But in the String and folder cases its exposes like this: - Heres the problem, this url ultimately redirects browser to:

So. like variable, I want to expose the url without  “url=blog” pattern.

So how can I do this? Here is my .htaccess file:

RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} -d RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.*)$ index.php?url=$1 [PT,L]
Solve problem with URL rewrite with .htaccess
4.7 (93.33%) 6 vote[s]

Steve-baker 1 year 0 Answers 244 views Novice 0

Leave an answer

About Steve-bakerNovice