Answer the question
In order to leave comments, you need to log in
How to make the right transition in htaccess?
Hello! There is a small problem - I'm making a link shortener like vk.cc.
There is a link.php file, which is located in the root of the site. You need to do this - when you just go to site.com/link, a page with a form for shortening the link opens, and when you go to site.com/link/sdsffdf, the page address is displayed.
In htaccess I wrote like this:
RewriteRule ^link/(.*)$ link.php?link=$1 [PT,L,QSA]
RewriteRule ^link/*$ link.php [L,QSA]
The problem is that when you go to site.com/link/sdsffdf, the site address changes to site.com/link/link/sdsffdf, that is, the link itself is duplicated. How to make it not change, but just site.com/link/sdsffdf?
Answer the question
In order to leave comments, you need to log in
known problem, easy to
fix
a
Math part of my friend;)
now looking ahead, in the case when a redirect from a page with a GET parameter: - it is not part of the url does not see RewriteRule
For this, a two-level construction with RewriteCond is used
And if it were necessary to redirect in the opposite direction.
RewriteCond %{QUERY_STRING} (^|&)link\=\$1($|&)
RewriteRule ^link\.php$ /link/? [L,R=301]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question