Reputation: 1090
I saw another stackoverflow answer to come up with this current setup. I want requests to http://myserver.com/book/1234 to actually show the content from php file http://myserver.com/book.php?id=1234
So my .htaccess looks like this:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} ^id=([0-9]*)$
RewriteRule ^book/(.*)$ /book.php?id=$1 [L]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [L]
Notice the bottom two lines allow me to use url's like http://myserver.php/login to actually pull up http://myserver.php/login.php This is working correctly. But I get a 500 Error when I try calling http://myserver.com/book/1234 What is wrong?
Upvotes: 1
Views: 75
Reputation: 9007
Your code is instructing the server to only do the rewrite if the query string is present. As a result, the rule would only work if you requested /book/1234?id=1234
.
Removing the line below will allow your rewrite to work.
RewriteCond %{QUERY_STRING} ^id=([0-9]*)$
Upvotes: 1