Forum Moderators: phranque
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
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
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
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
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
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
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