Forum Moderators: phranque
I've been been trying to rewrite some of my dynamic URLs to static ones but in vain.
The URLs are like http://www.example.com/links.php?page=2
and I want to change it to static php or HTML ones.
I've tried numerous time putting rewrite codes in my htaccess but still it doesn't seem to work.
I also have a couple of 301 redirection codes in my htaccess as well
The total file looks like:
RewriteEngine on
Options +FollowSymlinks
RewriteRule links-page-(.*)\.htm$ links.php?page=$1
rewritecond %{http_host} ^example.com [nc]
rewriterule ^(.*)$ http://www.example.com/$1 [r=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.php\ HTTP/
RewriteRule ^(.*)index\.php$ /$1 [R=301,L]
redirect 301 /links.php?page=2 http://www.example.com/links-page-2.html
redirect 301 /links.php?page=3 http://www.example.com/links-page-3.html
I feel I am making a mistake somewhere for which this isn't working. Kindly help me on this plzzzz...
Thanks a ton in advance!
[edited by: jdMorgan at 3:33 am (utc) on July 30, 2007]
[edit reason] example,com [/edit]
# Allow Rewrites and Redirects
RewriteEngine on
Options +FollowSymlinks
# Fix up Index URLs to "/" and force www at same time
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.php\ HTTP/
RewriteRule ^(.*)index\.php$ http://www.example.com/$1 [R=301,L]
# Externally redirect requests for Dynamic URLs to the Static equivalent and force www too
RewriteCond %{REQUEST_URI} ^links.php
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /links\.php\?paqe=([^&]+)\ HTTP/
RewriteRule ^links\.php http://www.example.com/links-page-%1.html [R=301,L]
# Fix non-www to www for all remaining non-www
RewriteCond %{HTTP_HOST} ^example\.com [nc]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
# Internally silently rewrite Static URL to Dynamic format
RewriteCond %{REQUEST_URI} ^links-page-
RewriteRule links-page-(.*)\.htm$ /links.php?page=$1 [L]
I hope this works. It is untested.
[edited by: jdMorgan at 3:35 am (utc) on July 30, 2007]
[edit reason] example.com [/edit]