PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, November 14, 2022

[FIXED] how to convert exrenal link to internal using .htaccess?

 November 14, 2022     .htaccess, external, hyperlink, redirect     No comments   

Issue

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]

Solution

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]


Answered By - CBroe
Answer Checked By - Marie Seifert (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing