Search code examples
phpapache.htaccessmod-rewriteamp-html

Is There A Way To Use PHP and Apache mod_rewrite to Generate AMP-HTML Versions of My Sites Pages?


I have a nationwide website that generates its pages and URLs dynamically using PHP and Apache mod_rewrite from a KML file on my server. I can't seem to find much documentation on using PHP with AMP-HTML and am genuinely curious if it is even possible?

I would like to generate an AMP version of my entire site, but my site is 30,000+ pages. So needless to say, that's a lot of work I would really try to avoid. Any help or advice would be great! Thanks in advance!


Solution

  • You may check this documentation on how to easily boost your AMP website combo with mod_rewrite. To get human readable and more SEOish addresses you're already using Apache's mod_rewrite in your .htaccess:

    RewriteEngine on
    RewriteRule \^([\^/]\*).html$ /index.php?page=$1 [L]
    

    You may check this Universal Google AMP Converter for Your Site Pages which allows any website — regardless of CMS, code, or other factors — to convert their pages into a Google AMP-compliant pages that will be indexed in search engines and other platforms that look for mobile AMP pages.