Jump to content

Clean Url Attempt: Fail


Lambneck

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/272495-clean-url-attempt-fail/
Share on other sites

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>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.