Welcome to WebmasterWorld Guest from 184.73.18.109

Forum Moderators: Ocean10000 & incrediBILL & phranque

mod_rewrite and browser address bar

   
8:24 am on Apr 4, 2003 (gmt 0)

10+ Year Member



Helo,

I enter on browser : [mydomain.com...]

I want the URL automates redirect to :
[mydomain.com...]

My .htaccess :

RewriteEngine on
RewriteRule ^ct /contact.php

This .htaccess didn't works!
Please ... somebody help me to solve this problem!

I have tested enter [mydomain.com...] and this works! but I want used old url, then mod_rewrite redirect it automated to new url and change the browser address bar to new URL,

regards

8:32 am on Apr 4, 2003 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



x_iyan,

Welcome to WebmasterWorld [webmasterworld.com]!

I enter on browser : [mydomain.com...]
I want the URL automates redirect to :
[mydomain.com...]

RewriteEngine on
RewriteRule ^contact\.php$ http://www.mydomain.com/ct/ [R=301,L]

More info: Introduction to mod_rewrite [webmasterworld.com]

Jim

8:47 am on Apr 4, 2003 (gmt 0)

10+ Year Member



Helo ...

Thanks morgan for answer me ...

I have tested but appears on my browser when I enter [mydomain.com...] :

Not Found
The requested URL /ct/ was not found on this server.
------------------------------------------------------------
Apache/1.3.27 Server at www.mydomain.com Port 80

regards
IYAN

4:39 pm on Apr 4, 2003 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Iyan,

This result shows that the code I posted does what you said you wanted it to do, but that the resource /ct/ does not exist.

If you redirect from
[mydomain.com...] to [mydomain.com...]
then [mydomain.com...] must be a resource that exists.

Please review the description you posted of what you want to do, and make sure it is correct.

Again, this Introduction to mod_rewrite [webmasterworld.com] might be helpful to you.

Jim

8:11 am on Apr 5, 2003 (gmt 0)

10+ Year Member



Helo,

you right morgan ...

Now we look again my .htaccess code :

RewriteEngine on
RewriteRule ^contact\.php$ [mydomain.com...] [R=301,L]

when i surf [mydomain.com...] the browser redirect to [mydomain.com...]
we know that no directory for /ct/, so browser said file not found,

So I change the .htaccess code to :

RewriteEngine on
RewriteRule ^ct /contact.php

and enter [mydomain.com...] .... wonderfull, works! but when I enter [mydomain.com...] the browser appear real contact.php and not redirect to [mydomain.com...]

so i add new code for .htaccess below :

RewriteEngine on
RewriteRule ^contact\.php$ [mydomain.com...] [R=301,L]
RewriteRule ^ct /contact.php

When I tried this code the browser said "limit bla bla bla"

I'm confuse ...

The right way is change our old link to new link with mod_rewrite rule, right? I mean we must change the old a href link to new link, eg :
<a href=http://www.mydomain.com/ct/>Contact</a>

and so ... .htaccess just look like :

RewriteEngine on
RewriteRule ^ct /contact.php

Isn't right? so ... I MUST CHANGE all of my old a href link to new link?

regards
IYAN

2:57 pm on Apr 5, 2003 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



IYAN,

mod_rewrite does not change links, it changes the mapping of requested URLs to filenames in the server.
The URL on the left is redirected to the "file" on the right. This happens before the server responds to a request. The resource on the right side of a RewriteRule must exist as a file.

RewriteRule ^AnyValid\.URL$ [yourdomain...] [R=301,L]

The above is simplified, as I suspect we have a language problem complicating the issue.

HTH,
Jim

4:14 pm on Apr 5, 2003 (gmt 0)

10+ Year Member



Helo,

I know that the file must be exist like u said ...

you know, we can map the url to new url that the files must not exist, look at :

RewriteEngine on
RewriteRule ^ct /contact.php

so when I open [mydomain.com...] it works and show the true contact.php file (browser address bar look : [mydomain.com...]

in this case, i don't want to change my old link
<a href=http://www.mydomain.com/contact.php>Contact</a>
I want mod_rewrite do redirect above link to [mydomain.com...] and then open the contact.php file, but I want that the browser address bar shown : [mydomain.com...]
it is possible? if yes, how the code?

yep, we have a language problem before, my english is not well, sorry ...

thanks in advance,
IYAN

 

Featured Threads

Hot Threads This Week

Hot Threads This Month