Eujinks
Eujinks

Reputation: 400

matching an exact .htaccess url (making it so if URL is longer then it isnt in effect)

I have a rewrite rule which is

RewriteEngine on
RewriteRule ^/whats-news/$ http://www.example.com/index.php/whats-news [R=301]

what I want to happen is if the user goes to www.example.com/whats-news then they are taken to www.example.com/index.php/whats-news BUT if they go to www.example.com/whats-news/admin.php then it shouldn't rewrite the url to be www.example.com/index.php/whats-news/admin.php.

but my current rule doesn't even work to redirect? Any thoughts?

Upvotes: 1

Views: 25

Answers (1)

anubhava
anubhava

Reputation: 785491

Try this rule:

RewriteEngine on

RewriteRule ^/?(whats-news)/?$ /index.php/$1 [R=301,L,NC]

Upvotes: 1

Related Questions