NarolaInfotech Demo
NarolaInfotech Demo

Reputation: 75

in htaccess first folder is not working with dashes

I have URL like this: http://example.com/apple_a/

I am using this rule:

RewriteEngine On  
RewriteRule ^([^_]*)-+(.*)$ $1_$2 [L,NC]

this is replacing other URL's like http://example.com/apple/a_a/a_b to "http://example.com/apple/a-a/a-b" (underscore with dashes) but when I write "_" in first directory like this "http://example.com/apple-a/a-a/" then its throwing 404 error.

So I wants that working somehow. Please help.

Upvotes: 1

Views: 48

Answers (1)

anubhava
anubhava

Reputation: 785128

Correct rule will be:

RewriteEngine On  
RewriteRule ^([^-]*)-+(.*)$ $1_$2 [L,NC]

You have ([^_]*) instead of ([^-]*)

Upvotes: 1

Related Questions