random1 Posted October 12, 2009 Share Posted October 12, 2009 All I need my code to do is replace the .php extension to .html I have the following code snippet in my .htaccess file: # Redirect .php files to .html files (SEO friendly) [internal and External] RewriteBase / RewriteRule ^(.*)\.php$ /$1.html [R=301,L] RewriteRule ^(.*)\.html$ $1.php [R=301,L] It redirects but it cuts out the folder name I have on the server. E.g. it redirects: https://localhost/website/admin.php to https://localhost/admin.html NOT https://localhost/website/admin.html as it should. Any ideas? Link to comment https://forums.phpfreaks.com/topic/177378-apache-redirectrewrite-php-extension-to-html/ Share on other sites More sharing options...
Baronen Posted October 18, 2009 Share Posted October 18, 2009 # Redirect .php files to .html files (SEO friendly) [internal and External] RewriteBase / RewriteRule ^(.*)\.php$ /$1.html [R=301,L] RewriteRule ^(.*)\.html$ $1.php [R=301,L] You have to change your RewriteBase from / to /website I think it would do the trick Link to comment https://forums.phpfreaks.com/topic/177378-apache-redirectrewrite-php-extension-to-html/#findComment-939322 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.