I am trying to set up a basic rewrite and it is not working. I want to be able to achieve the following:
http://www.example.com/view.php?page=1
Rewrite to
http://www.example.com/view/1
I have tried everything I can find and nothing seems to be working.
Any help appreciated.
UPDATE: These seems to be working but I requires the page to be redirected and I would prefer not to have to do that. The output is not exactly what I wanted as the querystring is still visible.
output: http://www.example.com/view/1?page=1
Options +FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} /view.php$
开发者_开发技巧 RewriteCond %{QUERY_STRING} ^page=([A-Za-z0-9\+]+)$
RewriteRule ^(.*)$ /view/%1 [R=301,QSA,L]
RewriteRule ^view/(.*)$ /view.php?page=$1&a=1 [L]
</IfModule>
Try this:
RewriteRule ^/view/([0-9]+)/?$ /view.php?page=$1
Try this:
RewriteEngine On
#rewriting rule to set last /
RewriteRule ^view/([0-9]+)$ /view/$1/ [QSA,R]
#rewriting rule to pass $1 as page that is the first element inside (...)
RewriteRule ^view/([0-9]+)/$ view.php?page=$1
Edit: Also make sure that your mod_rewrite module on apache is enabled ;)
精彩评论