1

I have an issue with url rewriting, here's what I have so far:

        Options +FollowSymlinks
        RewriteEngine on
        RewriteRule \.(gif|png|jpg|css|js)$|^index\.php$ - [L]
        RewriteRule ^users/(.+)$ /profile.php?userid=$1 [NC]
        RewriteRule ^(.+)/(.+)$ /main.php?region=$1&place=$2 [NC]

Basically, if the url is mysite.com/users/username I want it to use profile.php, then for anything else, to go to main.php.

However, with that code it doesn't happen as expected, it always uses main.php. Is there anyway you can use if and elses in htaccess, or something similar?

4

1 に答える 1

0

L2 番目と 3 番目のルールのフラグがありません。コードを次のようにします。

RewriteRule \.(gif|png|jpg|css|js)$|^index\.php$ - [L]
RewriteRule ^users/(.+)$ /profile.php?userid=$1 [NC,L,QSA]
RewriteRule ^(.+)/(.+)$ /main.php?region=$1&place=$2 [NC,L,QSA]
于 2012-10-31T21:13:32.940 に答える