1

I'm trying to make pretty url but want to put content title in url instead id, then i put content title in url with query string:

index.php?action=content&id=22

changed to:

index.php?action=content&title=stack-over-flow

it's works fine. now i trying to make it pretty but got a problem in htaccess code.

before removing id in url code was:

RewriteRule ^([a-z]+)/([0-9]+)/?$ index.php?action=$1&id=$2 [NC,L,QSA]

then i changed to:

RewriteRule ^([a-z]+)/([a-z]+)/?$ content.php?action=$1&title=$2 [NC,L,QSA]

but it's not working and i will back 300 Multiple Choices page. well, i think it's a httaccess problem, but i'm new in htaccess, need a hand to fix this.

want this:

/content/stack-over-flow

ITSolution
  • 398
  • 2
  • 9
  • 21

1 Answers1

1

Your regex is only allowing letters. It should also allow hyphen, numbers, upper case letters and underscore. Try this:

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([a-z]+)/([^/]+)/?$ content.php?action=$1&title=$2 [NC,L,QSA]
anubhava
  • 761,203
  • 64
  • 569
  • 643
  • just one question. it works when title is english, for non english title i got 300 multiple choices page again. it get non english character like this: /content/ÙØ±ÙˆØ´Ú¯Ø§Ù‡-جدید-Ú¯ÙˆÚ¯Ù„ what about this? – ITSolution Mar 13 '15 at 13:52