Reputation: 33
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'].
RewriteEngine on
RewriteRule ^home$ index.php [NC,L]
RewriteRule ^movies$ movies.php [NC,L]
RewriteRule ^movies/([0-9a-zA-Z_-]+)$ movies.php?u=$1 [NC,L]
Upvotes: 0
Views: 723
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
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