Lambneck Posted December 29, 2012 Share Posted December 29, 2012 So I have the below code doing two things. The first part removing .php extension from urls and the second part redirecting from a clean url to the original. Its the second part of this that is not working and I dont know why and am hoping and praying someone here can help with this. I have tried many different tutorials with different approaches and still no luck. Below is the most basic of the attempts I have tried and from what I can tell it SHOULD work, but alas... Anyway its trying to get the clean url example.com/post/2 to redirect to example.com/post.php?id=2 Please help! RewriteEngine On #remove .php extension RewriteCond %{REQUEST_FILENAME}.php -f RewriteCond %{REQUEST_URI} !/$ RewriteRule (.*) $1\.php [L] #redirect RewriteRule ^/post/([0-9]+)$ /post.php?id=$1 Quote Link to comment https://forums.phpfreaks.com/topic/272495-clean-url-attempt-fail/ Share on other sites More sharing options...
Lambneck Posted December 29, 2012 Author Share Posted December 29, 2012 Win! This is it: RewriteEngine On RewriteRule ^update/([0-9]+)$ update.php?id=$1 Quote Link to comment https://forums.phpfreaks.com/topic/272495-clean-url-attempt-fail/#findComment-1402086 Share on other sites More sharing options...
cpd Posted December 31, 2012 Share Posted December 31, 2012 (edited) That'll only redirect for requests that have a path starting with update. This could imply you're going to define every possible URL you have and redirect it? Why not redirect the whole thing and have PHP determine what content to serve up. <IfModule mod_rewrite.c> Options +FollowSymLinks RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [QSA,L] </IfModule> Edited December 31, 2012 by CPD Quote Link to comment https://forums.phpfreaks.com/topic/272495-clean-url-attempt-fail/#findComment-1402256 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.