Home > Mobile >  how to convert exrenal link to internal using .htaccess?
how to convert exrenal link to internal using .htaccess?

Time:07-14

i want convert all external link to internal and redirect them let me show you what i want: i have an external link to my website like this:

<a href ="https://external.com/some text here">link</a>

and i converted it to:

<a href ="https://mywebsite.com/redirect/https://external.com/some text here">link</a>
OR
<a href ="https://mywebsite.com/redirect=https://external.com/some text here">link</a>
OR somthing like this

how can i use .htaccess to make sure when someone opened the link he goes to:

https://external.com/some text here

i tried this but id didn't worked

RewriteEngine On
RewriteRule ^mywebsite.com/redirect/(.*)$ /$1 [NC,L]

CodePudding user response:

RewriteRule ^mywebsite.com/redirect/(.*)$ /$1 [NC,L]
  • RewriteRule only matches against the path component of the URL. (And when configured in .htaccess context, the path it checks against never starts with a leading slash, the path to the current directory has been stripped off at this point already.)

  • /$1 would cause a slash before the actual substitution URL.

Both fixed, it should simply look like this:

RewriteRule ^redirect/(.*)$ $1 [L]
  • Related