Jump to content

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

I have this:

 

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

 

and this url:

http://smydomain.com/test/3546

 

and its still using index.php

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.