Reputation: 57
I'm trying to rewrite /streams/post.php?id=1
into /streams/thread/1
.
I did find some codes for .htaccess with parameters but it didn't work in the subfolder.
Also, should I put another .htaccess in the subfolder or use the one on the main directory? ( /.htaccess
or /streams/.htaccess
)
Also, in the past when I've rewritten, sometimes it redirects from for example /streams/thread/1
to /streams/post.php?id=
and sometimes it actually displays /streams/thread/1
in the URL, I would like it to display /streams/thread/1
in the URL, not just redirect.
Upvotes: 3
Views: 1820
Reputation: 19016
You can put your htaccess in root or streams
folder (that's up to you).
In root folder
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} \s/streams/post\.php\?id=([0-9]*)\s [NC]
RewriteRule . streams/thread/%1? [R=301,L]
RewriteRule ^streams/thread/([0-9]+)$ streams/post.php?id=$1 [L]
In streams folder
RewriteEngine On
RewriteBase /streams/
RewriteCond %{THE_REQUEST} \s/streams/post\.php\?id=([0-9]*)\s [NC]
RewriteRule . thread/%1? [R=301,L]
RewriteRule ^thread/([0-9]+)$ post.php?id=$1 [L]
Upvotes: 2