slj90 Posted May 19, 2015 Share Posted May 19, 2015 My page structure is like this website.com/page/item?id=1234What do I need to add to my htaccess file to make it work when writing it like this website.com/page/item/1234My htaccess file currently hides the .php extenstion Thanks #Fix Rewrite Options -Multiviews # Mod Rewrite Options +FollowSymLinks RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php ErrorDocument 404 /error/404.php Quote Link to comment https://forums.phpfreaks.com/topic/296400-change-itemid1234-to-item1234-with-htaccess/ Share on other sites More sharing options...
requinix Posted May 19, 2015 Share Posted May 19, 2015 RewriteRule ^page/item/(\d+)$ page/item.php?id=$1 [L,QSA]There's no point omitting the .php here as the user won't see it and it would make Apache work that much harder to route the request. Quote Link to comment https://forums.phpfreaks.com/topic/296400-change-itemid1234-to-item1234-with-htaccess/#findComment-1512238 Share on other sites More sharing options...
slj90 Posted May 19, 2015 Author Share Posted May 19, 2015 RewriteRule ^page/item/(\d+)$ page/item.php?id=$1 [L,QSA]There's no point omitting the .php here as the user won't see it and it would make Apache work that much harder to route the request. Hi, Thanks for your reply. When I add that liine I receive the following error " Internal Server ErrorThe server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator and inform them of the time the error occurred, and the actions you performed just before this error. More information about this error may be available in the server error log. " Thanks, Quote Link to comment https://forums.phpfreaks.com/topic/296400-change-itemid1234-to-item1234-with-htaccess/#findComment-1512247 Share on other sites More sharing options...
requinix Posted May 19, 2015 Share Posted May 19, 2015 It's probably making a loop. Add an [R] flag and see where you're being redirected to. You may need your browser's console, or an extension, to see the traffic if the URL isn't changing. And to be sure, what's your full .htaccess now? Quote Link to comment https://forums.phpfreaks.com/topic/296400-change-itemid1234-to-item1234-with-htaccess/#findComment-1512250 Share on other sites More sharing options...
slj90 Posted June 13, 2015 Author Share Posted June 13, 2015 (edited) Hello, It's #Fix Rewrite Options -Multiviews # Mod Rewrite Options +FollowSymLinks RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php RewriteRule ^page/item/(\d+)$ page/item.php?id=$1 [L,QSA] ErrorDocument 404 /error/404.php Edited June 13, 2015 by slj90 Quote Link to comment https://forums.phpfreaks.com/topic/296400-change-itemid1234-to-item1234-with-htaccess/#findComment-1513792 Share on other sites More sharing options...
requinix Posted June 14, 2015 Share Posted June 14, 2015 1. What does the error log say about the 500 error? 2. If you use the [R] flag I mentioned, where does your browser get redirected to? If there is a loop then you might not see it and have to look at the server's response headers to find out. Quote Link to comment https://forums.phpfreaks.com/topic/296400-change-itemid1234-to-item1234-with-htaccess/#findComment-1513819 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.