Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Mar 2011
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How do I forward AND mask a URL with HTACCESS?

    I want to be able to type in URL1 which forwards visitor to URL2 but I want URL1 to still show in the address bar. I believe this involves the HTACCESS file and rewrite command, but I do not know the code. Please specifically tell me what code and where to insert the URL1 and URL2? Thanks!!!!!!!!!!

  • #2
    Regular Coder
    Join Date
    Mar 2011
    Posts
    148
    Thanks
    0
    Thanked 20 Times in 20 Posts
    Hi,
    You need mod-rewrite.
    Just look on the net for: " htaccess mod rewrite " .
    Here is an example:
    URL1 (added in <a> tag, and displayed in adress bar): http://www.coursesweb.net/php-mysql/tutorials_t
    URL2 (where URL1 redirects): http://www.coursesweb.net/index.php?t=php-mysql&p=tutorials
    In htaccess, this code:
    Code:
    Options +FollowSymLinks
    RewriteEngine On
    
    RewriteRule ^php-mysql/([A-Za-z0-9-_]+)_t$ index.php?t=php-mysql&p=$1 [NC,L]
    Last edited by MarPlo; 07-26-2012 at 07:23 PM.

  • #3
    New Coder
    Join Date
    Mar 2011
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by MarPlo View Post
    Hi,
    You need mod-rewrite.
    Just look on the net for: " htaccess mod rewrite " .
    Here is an example:
    URL1 (added in <a> tag, and displayed in adress bar): http://www.coursesweb.net/php-mysql/tutorials_t
    URL2 (where URL1 redirects): http://www.coursesweb.net/index.php?...ql&p=tutorials
    In htaccess, this code:
    Code:
    Options +FollowSymLinks
    RewriteEngine On
    
    RewriteRule ^php-mysql/([A-Za-z0-9-_]+)_t$ index.php?t=php-mysql&p=$1 [NC,L]
    Sorry, but not quite getting it. Don't I have to insert the URL1 and URL2 somewhere in that code? Where do I insert these? Also, please remember I am trying to also mask, not only forward so that URL1 still shows in the address bar.

  • #4
    Regular Coder
    Join Date
    Mar 2011
    Posts
    148
    Thanks
    0
    Thanked 20 Times in 20 Posts
    Hi
    The URL1 is added in the links <a> in the page, it still shows in the address bar.
    For more details, look on the net for " htaccess mod rewrite tutorial ", you can learn by yourself.
    Last edited by MarPlo; 07-26-2012 at 08:03 PM.

  • #5
    New Coder
    Join Date
    Mar 2011
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by MarPlo View Post
    Hi
    The URL1 is added in the links <a> in the page, it still shows in the address bar.
    For more details, look on the net for " htaccess mod rewrite tutorial ", you can learn by yourself.
    Well I couldn't find specifically the help I needed on google which is why I am seeking help here.

    Secondly, you provided some code for the HTACCESS file above, but I do not know where to place the <a> tag with my URL1 and URL2 within that code.
    Last edited by awdevore; 07-27-2012 at 04:15 AM.

  • #6
    New Coder
    Join Date
    Mar 2011
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Can anyone help?


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •