avinash
avinash

Reputation: 33

.htaccess rewriter rule working in localhost but not on live server

My .htaccess file. I have index.php and movies.php. www.website.com/movies working fine in both localhost and live server. but www.website.com/movies/movie-title working perfectly in localhost but not in live server. I don't know the problem. In movies.php page, i'm showing the list of titles if we use www.website.com/movies and i'm trying to show single element if we access www.website.com/movies/movie-title by trying to use $_GET['u'].

Turn Rewrite Engine On

RewriteEngine on

Rewrite for index.php

RewriteRule ^home$ index.php [NC,L]

Rewrite for moviespage.php

RewriteRule ^movies$ movies.php [NC,L]

Rewrite for movies.php?u=xxxxx

RewriteRule ^movies/([0-9a-zA-Z_-]+)$ movies.php?u=$1 [NC,L]

Upvotes: 0

Views: 723

Answers (2)

Iam NoOne
Iam NoOne

Reputation: 1

Instead of

RewriteRule ^movies/([0-9a-zA-Z_-]+)$ movies.php?u=$1 [NC,L]

Try This

RewriteRule ^movies/([0-9a-zA-Z_-]+)$ /movies.php?u=$1 [NC]

/movies.php will let the server understand which url, to be exact, need to be rewritten. Since every page on live server is identified via '/' (forward slash) and the file extension (.php, in this case).

In the syntax,

L = to stop processing the rule further

NC = Process rule to next with case-insensitivity

Upvotes: 0

web-stars
web-stars

Reputation: 127

This works for me:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

Let me know if it works for you!

Upvotes: 0

Related Questions