Jump to content

[SOLVED] Help with Rule


Warriorpt

Recommended Posts

Hi everyone,

 

i have in my htacess this:

 

#Rewrite Rules

RewriteRule ^match/([0-9]+)$ ?k=match&id=$1

RewriteRule ^([a-zA-Z0-9]+)/$ ?k=about

RewriteRule ^([a-zA-Z0-9]+)$ ?k=about

RewriteRule ^([a-zA-Z0-9]+)/$ ?k=matches

RewriteRule ^([a-zA-Z0-9]+)$ ?k=matches

 

but, in my website, when i try to call /matches/ the website open the /about/ page.

 

If i change to:

 

#Rewrite Rules

RewriteRule ^match/([0-9]+)$ ?k=match&id=$1

RewriteRule ^([a-zA-Z0-9]+)/$ ?k=matches

RewriteRule ^([a-zA-Z0-9]+)$ ?k=matches

RewriteRule ^([a-zA-Z0-9]+)/$ ?k=about

RewriteRule ^([a-zA-Z0-9]+)$ ?k=about

 

The /matches/ page open, but when i click in /about/, it opens the matches page.

There are some way to repair that?

Link to comment
https://forums.phpfreaks.com/topic/109304-solved-help-with-rule/
Share on other sites

Hi there

 

In your first example, if you access "/matches/" the second rule is redirecting you to your about page. This is because ^([a-zA-Z0-9]+)/$ is trying to find any combination of letters and numbers and a slash, which includes the string "/matches/". If you want something else to happen when you access "/matches/", create rules like this:

 

RewriteRule ^matches/?$ ?k=matches

RewriteRule ^about/?$ ?k=about

 

The question mark is useful before the slash as it means with or without the preceding character. Hope this helps.

 

Jamie

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.