user317005
user317005

Reputation:

SEO friendly URLs (.htaccess)

http://www.domain.com/folder/file?x=1&y=2

Change to:

http://www.domain.com/folder/file/1/2/

http://www.domain.com/folder/?x=1

Change to:

http://www.domain.com/folder/1/

I tried:

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^folder/(.*)/$ folder/index.php?x=$1 [L]
RewriteRule ^folder/file/(.*)/(.*)/$ folder/file.php?x=$1&y=$2 [L]

but that doesn't work, does anyone have any idea why?

when i take out the first rule, i can access the second one via:

http://www.domain.com/folder/1/2/

but not:

http://www.domain.com/folder/file/1/2/

god, i hope i am not confusing anyone who is reading this lol i hope it makes sense

Upvotes: 1

Views: 3895

Answers (2)

Matt Asbury
Matt Asbury

Reputation: 5662

Try

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^folder/file/(.*)/(.*)/ /folder/file.php?x=$1&y=$2 [L]
RewriteRule ^folder/(.*)/ /folder/index.php?x=$1 [L]

The order of the rules is important. You should always put the one with the most rules first as your way was getting to the first rule and then stopping because it was always true due to the (.*) which was capturing the file.

Upvotes: 1

Kyle
Kyle

Reputation: 1733

Did you try adding a / before the folder name?

RewriteRule ^folder/(.*)/$ /folder/index.php?x=$1 [L]
RewriteRule ^folder/file/(.*)/(.*)/$ /folder/file.php?x=$1&y=$2 [L]

Upvotes: 0

Related Questions