Htaccess PHP Redirecting. Unable to do so.. 404 not found error
I am working on a ask answer website and thanks to Alex, I got the permalinks I wanted to have on the website (PHP Permalinks.. how to change?).
Here is the format..
Original: domainname.com/cat/how-are-you-|162
New permalinks: domainname.com/cat/how-are-you-|162.html
The new permalinks won't work i.e, it doesn't load the page and displays 404 Not found error. My knowledge of rewriterules are very basics, I did try some functions but to my dismay, they didn't work at all.
How do I redirect original to the开发者_JAVA技巧 new permalinks using htaccess file?
Thank you.
Edit1: @Ignacio - Currently, I haven't implemented it on the server as I don't want to lose traffic, but I can do it once again tonite and will update with the result.
@Pekka - Here is the .htaccess file http://pastebin.com/m23c7d2b6
You want to do two things:
- Permanently redirect old permalinks to new permalinks and
- Make new permalinks work.
To redirect the old permalinks, add something like this:
RewriteCond %{REQUEST_FILENAME} !.*\.html$ RewriteRule ^(.+/.+)$ $1.html [L,R=301]
To get the new permalinks to work, change this line:
RewriteRule ^([^/.]+)/([^/.]*)?$ view.php?title=$1&id=$2&%{QUERY_STRING}
to this:
RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^/.]+)/([^/.]*)\.html?$ view.php?title=$1&id=$2&%{QUERY_STRING}
精彩评论