homepage Welcome to WebmasterWorld Guest from 50.17.79.35
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
mod_rewrite and browser address bar
x_iyan




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

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

 

jdMorgan




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

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

x_iyan




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

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

jdMorgan




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

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

x_iyan




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

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

jdMorgan




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

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

x_iyan




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

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved