Jump to content

mod rewrite


ohdang888

Recommended Posts

When someone types in www.mydomain.com/a3kd  .... i want it to go to photo.php?id=a3kd

But when someone types in www.mydomain.com/contact i want it to go to the contact folder, index.php

 

So, i have this rule:

RewriteEngine on
RewriteRule ^(.*+)$ photo.php?id=$1

 

BUT, that redirects the www.mydomain.com/contact to photo.php?id=contact.

 

Any ideas?

 

Oh ya, and the "id" may be between 4 and 10 characters long

 

Thanks!

 

 

Link to comment
https://forums.phpfreaks.com/topic/162818-mod-rewrite/
Share on other sites

one more question.

 

how does mod rewrite decide which one of the following to use in the case of:

www.mydomain.com/test/154534

 

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*+)$ index.php?id=$1
RewriteRule ^test/(.*+)$ testing1234.php?id=$1

 

b/c right now, its directing that url to index.php even though i declare "test" in it.

Link to comment
https://forums.phpfreaks.com/topic/162818-mod-rewrite/#findComment-859194
Share on other sites

It matches as long as it can and as long as you don't stop the chain.

 

So www.mydomain.com/test/154534 matches the first rule, and it becomes www.mydomain.com/index.php?id=test/154534, which doesn't match any further rules.

 

You can switch the rules around and add [L] to the one with "test", or you can limit the regex in the current first one.

Link to comment
https://forums.phpfreaks.com/topic/162818-mod-rewrite/#findComment-859199
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.