0

hiii ,

I want to rewrite the directory www.mysite.com/index.php?category=news to www.mysite.com/news I write this code but its doesn't work anyone can help, please thanks for help

RewriteEngine On    
RewriteRule  ^([a-zA-Z0-9-/]+)$ index.php?category=$1

Thanks for all who answered my question , all the codes are work when i try to write www.mysite.com/news , but I mean when i click on a link "a href='index.php?category=news'"link"/a" I want to be rewrite to www.mysite.com/news immediately

3
  • What happens when you go to mysite.com/news? Commented Oct 18, 2011 at 22:23
  • I'm fairly certain you mean "rewrite news to index.php?category=news" and not the other way around Commented Oct 18, 2011 at 22:37
  • levi Morrison , its works but I mean when i click on a link "a href='index.php?category=news'"link"/a" I want to be rewrite to www.mysite.com/news immediately Commented Oct 19, 2011 at 8:05

4 Answers 4

1

Just to confirm, the pattern you want to match is all letters, numbers, hyphens and forward-slashes, right?

If so, try this

RewriteRule ^([a-zA-Z0-9/-]+)$ index.php?category=$1 [QSA,L]

I think the problem may have been your ordering of the hyphen and forward-slash in the character class expression. To match hyphens, they should appear first or last in the set of characters.

Sign up to request clarification or add additional context in comments.

Comments

0

Does this work?

RewriteBase /
RewriteRule (.*) index.php?category=$1 [QSA,NC,L]

Comments

0

try this

Options +FollowSymLinks
RewriteEngine on
RewriteRule news/ index.php?category=news
RewriteRule news index.php?category=news

Comments

0
RewriteRule ^(news|or|some|other|category)$ index.php?category=$1 [QSA,NC,L]

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.