StudioTime
StudioTime

Reputation: 23959

Mod rewrite not rewriting as it should

This is original URL:

http://myurl.com/entertainment/act-view.html?act_name=good-duo

Which I want to be able to write instead as:

http://myurl.com/entertainment/good-duo

Here's what I'm trying but get 500 Internal Server Error

RewriteEngine On
RewriteRule ^entertainment/([^/]*)$ /entertainment/act-view.html?act_name=$1 [L]

Upvotes: 1

Views: 44

Answers (1)

anubhava
anubhava

Reputation: 784898

You're getting 500 because of looping since your regex is this:

^entertainment/([^/]*)$

Which matches URI before and after rewrite i.e. of these

/entertainment/good-duo
/entertainment/act-view.html

You can use this rule:

# If the request is not for a valid file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^entertainment/([^/]*)/?$ /entertainment/act-view.html?act_name=$1 [L,QSA,NC]

OR this:

RewriteRule ^entertainment/([^/.]*)/?$ /entertainment/act-view.html?act_name=$1 [L,QSA,NC]

Upvotes: 1

Related Questions