rewrite url is not working in core php localhost project

278 views Asked by At

I have to to make my URL into a friendly URL.

I have this in my .htaccess file:

RewriteRule http://localhost/test/client/this_is_test_page.php$ http://localhost/test/test-page [NC,R=301,L]

but now I'm getting HTTP 500 internal server error.

What could be causing this, and how can I fix it?

1

There are 1 answers

5
Oulalahakabu On

You should not have HTTP_HOST in your pattern according to the apache documentation :

A RewriteRule consists of three arguments separated by spaces. The arguments are :

  1. Pattern: which incoming URLs should be affected by the rule;
  2. Substitution: where should the matching requests be sent;
  3. [flags]: options affecting the rewritten request.

The Pattern is a regular expression. It is initially (for the first rewrite rule or until a substitution occurs) matched against the URL-path of the incoming request (the part after the hostname but before any question mark indicating the beginning of a query string)

Your rule should be something like :

RewriteRule /test/client/this_is_test_page.php$ /test/test-page [NC,R=301,L]

And you should have mod_rewrite enabled, RewriteEngine On and AllowOverride.