.htaccess modrewrite problem
I have a website on wordpress and I have written a plugin which required SEO friendly URL now i am stuck at the following
http://domain.com/catalogue-category/1/
is working fine but when i replace the /1/
with the name of the category like http://domain.com/catalogue-category/Seating/
it does not work at all and gives me 404
error.
Its also working at /catalogue-category/?cat=Seating
My apache rewrite rule is
RewriteRule ^catalogue-category/^([^/]+)/$ /catalogue-category/?cat=$1 [L]
I am not that good in mod rewrite as that in PHP, so please bear my ignorance and treat me as a rookie.
Looking forward to hear 开发者_开发技巧from the gurus :)
Try:
RewriteRule ^catalogue-category/([^/]+)/$ /catalogue-category/?cat=$1 [L]
You were using the caret ^
twice in your regex pattern (^catalogue-category/^([^/]+)/$
), the caret asserts that the match should be from the start of the string.
Pattern explanations
Previous pattern:
- Assert position at the beginning of the string «^»
- Match the characters “catalogue-category/” literally «catalogue-category/»
- Assert position at the beginning of the string «^»
- Match the regular expression below and capture its match into backreference number 1 «([^/]+)»
- Match any character that is NOT a “/” «[^/]+»
- Between one and unlimited times, as many times as possible, giving back as needed (greedy) «+»
- Match the character “/” literally «/»
- Assert position at the end of the string (or before the line break at the end of the string, if any) «$»
Suggested one
- Assert position at the beginning of the string «^»
- Match the characters “catalogue-category/” literally «catalogue-category/»
- Match the regular expression below and capture its match into backreference number 1 «([^/]+)»
- Match any character that is NOT a “/” «[^/]+»
- Between one and unlimited times, as many times as possible, giving back as needed (greedy) «+»
- Match the character “/” literally «/»
- Assert position at the end of the string (or before the line break at the end of the string, if any) «$»
精彩评论