Go Back   CodingForums.com > :: Server side development > Apache configuration

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-26-2012, 04:00 PM   PM User | #1
awdevore
New Coder

 
Join Date: Mar 2011
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
awdevore is an unknown quantity at this point
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!!!!!!!!!!
awdevore is offline   Reply With Quote
Old 07-26-2012, 06:18 PM   PM User | #2
MarPlo
Regular Coder

 
Join Date: Mar 2011
Posts: 145
Thanks: 0
Thanked 20 Times in 20 Posts
MarPlo is an unknown quantity at this point
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 06:23 PM..
MarPlo is offline   Reply With Quote
Old 07-26-2012, 06:53 PM   PM User | #3
awdevore
New Coder

 
Join Date: Mar 2011
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
awdevore is an unknown quantity at this point
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.
awdevore is offline   Reply With Quote
Old 07-26-2012, 07:00 PM   PM User | #4
MarPlo
Regular Coder

 
Join Date: Mar 2011
Posts: 145
Thanks: 0
Thanked 20 Times in 20 Posts
MarPlo is an unknown quantity at this point
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 07:03 PM..
MarPlo is offline   Reply With Quote
Old 07-26-2012, 08:21 PM   PM User | #5
awdevore
New Coder

 
Join Date: Mar 2011
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
awdevore is an unknown quantity at this point
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 03:15 AM..
awdevore is offline   Reply With Quote
Old 07-27-2012, 03:14 AM   PM User | #6
awdevore
New Coder

 
Join Date: Mar 2011
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
awdevore is an unknown quantity at this point
Can anyone help?
awdevore is offline   Reply With Quote
Reply

Bookmarks

Tags
htacess, mask url, mask url htaccess

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:45 PM.


Advertisement
Log in to turn off these ads.