Reputation: 483
I cannot get this to work. I want
http://localhost/test/post.php?id=15
to show
http://localhost/test/post/15
My attempt loads a page without css on it and shows me my customr 404 error page
Options -Indexes -MultiViews +FollowSymlinks
RewriteEngine On
RewriteBase /test/
ErrorDocument 404 /errors/404.php
RewriteCond %{QUERY_STRING} ^id=(.+)$ [NC]
RewriteRule ^post\.php post/%1? [R,L]
please help me out!
Upvotes: 1
Views: 45
Reputation: 785128
You will need to %{THE_REQUEST}
variable for this. THE_REQUEST
variable represents original request received by Apache from your browser and it doesn't get overwritten after execution of some rewrite rules. Example value of this variable is GET /index.php?id=123 HTTP/1.1
.
Your code will be:
ErrorDocument 404 /errors/404.php
Options -Indexes -MultiViews +FollowSymlinks
RewriteEngine On
RewriteBase /test/
RewriteCond %{THE_REQUEST} /post\.php\?id=([^\s&]+) [NC]
RewriteRule ^ post/%1? [R=302,L]
RewriteRule ^post/([^/.]+)/?$ post.php?id=$1 [L,QSA,NC]
Upvotes: 1