Forum Moderators: phranque

Message Too Old, No Replies

Problem rewriting static to dynamic URL

plz help am getting crazy

         

smagdy

12:37 pm on May 14, 2005 (gmt 0)

10+ Year Member



What is wrong in this?

I tried:

RewriteRule ^(/1)$ /phones.php?c=$1 [L]
RewriteRule ^/1$ /phones.php?c=$1 [L]
RewriteRule ^(1)$ /phones.php?c=$1 [L]

it says the page cannot be found...

the host told me that the mod_rewrite is installed and functioning on all servers.

There was some stuff written in .htacess file by default so I wrote my rules after it direct.

so what should i try now?

smagdy

1:03 pm on May 14, 2005 (gmt 0)

10+ Year Member



Both files are in sub directory..

for ex.

I want to redirect

www.mydomain.com/sub/file.php?c=1

to

www.mydomain.com/sub/1

so the above 3 rules didnt work...

Thanks in advance

smagdy

1:26 pm on May 14, 2005 (gmt 0)

10+ Year Member



it worked when i wrote:

RewriteRule /1 /mob/phones.php?c=1

but that doesnt look like any other Rule ive seen before..

why did it work without ^ and $

jdMorgan

4:12 pm on May 14, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



^ and $ are start and end anchors. If you use them, the requested local URL-path must match exactly, starting and ending on the specified pattern boudaries. See the regular-expressions tutorial cited in our Charter [webmasterworld.com].

If your rule is in your Web root directory .htaccess, then a proper form would be:


RewriteRule ^sub/(.+)$ /sub/file.php?c=$1 [L]

Terminology/usage comments:
This rewrites requests for www.mydomain.com/sub/1 to www.mydomain.com/sub/file.php?c=1
Also note that this is an internal ('silent' or 'transparent') rewrite, not an external redirect.
Recognizing these details makes understanding the process easier.

Jim